Skip to content

Commit

Permalink
Fix exiv2 -pR for Sony images (Exiv2#1805)
Browse files Browse the repository at this point in the history
`exiv2 -pR` failed to process Sony makernotes. Fix checks if
makernotes header has Sony string, then uses correct offset.

Fix supplied by @clanmills
  • Loading branch information
postscript-dev committed Sep 26, 2021
1 parent b27aa0b commit 3742760
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,11 @@ namespace Exiv2 {
seekOrThrow(io, offset, BasicIo::beg, kerCorruptedMetadata); // position
readOrThrow(io, bytes, jump, kerCorruptedMetadata) ; // read
bytes[jump]=0 ;
if ( ::strcmp("Nikon",chars) == 0 ) {

bool bNikon = ::strcmp("Nikon" ,chars) == 0;
bool bSony = ::strcmp("SONY DSC ",chars) == 0;

if ( bNikon ) {
// tag is an embedded tiff
const long byteslen = count-jump;
DataBuf bytes(byteslen); // allocate a buffer
Expand All @@ -499,8 +503,9 @@ namespace Exiv2 {
printTiffStructure(memIo,out,option,depth);
} else {
// tag is an IFD
uint32_t punt = bSony ? 12 : 0 ;
seekOrThrow(io, 0, BasicIo::beg, kerCorruptedMetadata); // position
printIFDStructure(io,out,option,offset,bSwap,c,depth);
printIFDStructure(io,out,option,offset+punt,bSwap,c,depth);
}

seekOrThrow(io, restore, BasicIo::beg, kerCorruptedMetadata); // restore
Expand Down

0 comments on commit 3742760

Please sign in to comment.