Skip to content

Commit

Permalink
Merge pull request #1929 from postscript-dev/fix_exiv2_-pR
Browse files Browse the repository at this point in the history
Fix `exiv2 -pR` for Sony images (#1805)
  • Loading branch information
postscript-dev authored Jan 9, 2022
2 parents a098ab6 + 6758e72 commit 629442d
Show file tree
Hide file tree
Showing 2 changed files with 29 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 @@ -477,7 +477,11 @@ namespace Exiv2 {
io.seekOrThrow(offset, BasicIo::beg, kerCorruptedMetadata); // position
io.readOrThrow(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 @@ -486,8 +490,9 @@ namespace Exiv2 {
printTiffStructure(memIo,out,option,depth);
} else {
// tag is an IFD
uint32_t punt = bSony ? 12 : 0 ;
io.seekOrThrow(0, BasicIo::beg, kerCorruptedMetadata); // position
printIFDStructure(io,out,option,offset,bSwap,c,depth);
printIFDStructure(io,out,option,offset+punt,bSwap,c,depth);
}

io.seekOrThrow(restore, BasicIo::beg, kerCorruptedMetadata); // restore
Expand Down
22 changes: 22 additions & 0 deletions tests/bugfixes/github/test_issue_1805.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-

import unittest
import system_tests
from system_tests import CaseMeta, path, check_no_ASAN_UBSAN_errors

# Check that `exiv2 -pr` works for different file types.
# ExifTool has a list of markers that appear in the headers:
# https://exiftool.org/makernote_types.html

@unittest.skip("Skipping test using option -pR (only for Debug mode)")
class exiv2pRHeaderTest(metaclass=CaseMeta):

url = "https://github.com/Exiv2/exiv2/issues/1805"

filename = system_tests.path("$data_path/exiv2-SonyDSC-HX60V.exv") # Uses marker: "SONY DSC "
commands = ["$exiv2 -pR " + filename]

stderr = [""]
retval = [0]

compare_stdout = check_no_ASAN_UBSAN_errors

0 comments on commit 629442d

Please sign in to comment.