Skip to content

Commit 629442d

Browse files
Merge pull request #1929 from postscript-dev/fix_exiv2_-pR
Fix `exiv2 -pR` for Sony images (#1805)
2 parents a098ab6 + 6758e72 commit 629442d

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/image.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,11 @@ namespace Exiv2 {
477477
io.seekOrThrow(offset, BasicIo::beg, kerCorruptedMetadata); // position
478478
io.readOrThrow(bytes, jump, kerCorruptedMetadata) ; // read
479479
bytes[jump]=0 ;
480-
if ( ::strcmp("Nikon",chars) == 0 ) {
480+
481+
bool bNikon = ::strcmp("Nikon" ,chars) == 0;
482+
bool bSony = ::strcmp("SONY DSC ",chars) == 0;
483+
484+
if ( bNikon ) {
481485
// tag is an embedded tiff
482486
const long byteslen = count-jump;
483487
DataBuf bytes(byteslen); // allocate a buffer
@@ -486,8 +490,9 @@ namespace Exiv2 {
486490
printTiffStructure(memIo,out,option,depth);
487491
} else {
488492
// tag is an IFD
493+
uint32_t punt = bSony ? 12 : 0 ;
489494
io.seekOrThrow(0, BasicIo::beg, kerCorruptedMetadata); // position
490-
printIFDStructure(io,out,option,offset,bSwap,c,depth);
495+
printIFDStructure(io,out,option,offset+punt,bSwap,c,depth);
491496
}
492497

493498
io.seekOrThrow(restore, BasicIo::beg, kerCorruptedMetadata); // restore
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import unittest
4+
import system_tests
5+
from system_tests import CaseMeta, path, check_no_ASAN_UBSAN_errors
6+
7+
# Check that `exiv2 -pr` works for different file types.
8+
# ExifTool has a list of markers that appear in the headers:
9+
# https://exiftool.org/makernote_types.html
10+
11+
@unittest.skip("Skipping test using option -pR (only for Debug mode)")
12+
class exiv2pRHeaderTest(metaclass=CaseMeta):
13+
14+
url = "https://github.com/Exiv2/exiv2/issues/1805"
15+
16+
filename = system_tests.path("$data_path/exiv2-SonyDSC-HX60V.exv") # Uses marker: "SONY DSC "
17+
commands = ["$exiv2 -pR " + filename]
18+
19+
stderr = [""]
20+
retval = [0]
21+
22+
compare_stdout = check_no_ASAN_UBSAN_errors

0 commit comments

Comments
 (0)