diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index a6bf925bd7..a93b4592fc 100644 --- a/src/tiffcomposite_int.cpp +++ b/src/tiffcomposite_int.cpp @@ -30,6 +30,7 @@ #include "tiffcomposite_int.hpp" #include "tiffvisitor_int.hpp" #include "makernote_int.hpp" +#include "sonymn_int.hpp" #include "value.hpp" #include "error.hpp" #include "enforce.hpp" @@ -1402,7 +1403,7 @@ namespace Exiv2 { // Tags must be sorted in ascending order std::sort(elements_.begin(), elements_.end(), cmpTagLt); uint32_t idx = 0; - MemIo mio; + MemIo mio; // memory stream in which to store data IoWrapper mioWrapper(mio, 0, 0, 0); // Some array entries need to have the size in the first element if (cfg()->hasSize_) { @@ -1433,16 +1434,20 @@ namespace Exiv2 { uint16_t lastTag = static_cast(lastDef->idx_ / cfg()->tagStep()); idx += fillGap(mioWrapper, idx, lastDef->idx_ + lastDef->size(lastTag, cfg()->group_)); } - DataBuf buf; + if (cfg()->cryptFct_) { - buf = cfg()->cryptFct_(tag(), mio.mmap(), static_cast(mio.size()), pRoot_); - } - if (buf.size_ > 0) { - ioWrapper.write(buf.pData_, buf.size_); - } - else { - ioWrapper.write(mio.mmap(), static_cast(mio.size())); + // Select sonyTagEncipher + CryptFct cryptFct = cfg()->cryptFct_; + if ( cryptFct == sonyTagDecipher ) { + cryptFct = sonyTagEncipher; + } + DataBuf buf = cryptFct(tag(), mio.mmap(), static_cast(mio.size()), pRoot_); + if ( buf.size_) { + mio.seek(0,Exiv2::FileIo::beg); + mio.write(buf.pData_, buf.size_); + } } + ioWrapper.write(mio.mmap(), static_cast(mio.size())); return idx; } // TiffBinaryArray::doWrite diff --git a/test/data/test_issue_1471.exv b/test/data/test_issue_1471.exv new file mode 100644 index 0000000000..92389917ed Binary files /dev/null and b/test/data/test_issue_1471.exv differ diff --git a/test/data/test_issue_1472.jpg b/test/data/test_issue_1472.jpg new file mode 100644 index 0000000000..92389917ed Binary files /dev/null and b/test/data/test_issue_1472.jpg differ diff --git a/tests/bugfixes/github/test_issue_1471.py b/tests/bugfixes/github/test_issue_1471.py new file mode 100644 index 0000000000..593865a938 --- /dev/null +++ b/tests/bugfixes/github/test_issue_1471.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +from system_tests import CaseMeta, CopyTmpFiles, path +@CopyTmpFiles("$data_path/test_issue_1471.exv") + +class test_issue_1471Test(metaclass=CaseMeta): + + filename = path("$tmp_path/test_issue_1471.exv") + commands = [ "$exiv2 -K Exif.Sony2010e.WB_RGBLevels $filename" + , "$exiv2 -M\"set Exif.Image.ImageID foobar\" $filename" + , "$exiv2 -K Exif.Sony2010e.WB_RGBLevels $filename" + ] + stdout = ["Exif.Sony2010e.WB_RGBLevels Short 3 598 256 442\n" + ,"" + ,"Exif.Sony2010e.WB_RGBLevels Short 3 598 256 442\n" + ] + stderr = [""]*len(commands) + retval = [ 0]*len(commands) diff --git a/tests/bugfixes/github/test_issue_1472.py b/tests/bugfixes/github/test_issue_1472.py new file mode 100644 index 0000000000..8ada33832b --- /dev/null +++ b/tests/bugfixes/github/test_issue_1472.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +from system_tests import CaseMeta, CopyTmpFiles, path +@CopyTmpFiles("$data_path/test_issue_1472.jpg") + +class test_issue_1472Test(metaclass=CaseMeta): + + filename = path("$tmp_path/test_issue_1472.jpg") + exvfile = path("$tmp_path/test_issue_1472.exv") + commands = [ "rm -rf $exvfile" + , "$exiv2 -pa --grep LensType2 $filename" + , "$exiv2 ex $filename" + , "$exiv2 -pa --grep LensType2 $exvfile" + , "$exiv2 rm $filename" + , "$exiv2 -pa --grep LensType2 $filename" + , "$exiv2 in $filename" + , "$exiv2 -pa --grep LensType2 $filename" + ] + stdout = ["" + ,"Exif.Sony2010e.LensType2 Short 1 1024\n" + ,"" + ,"Exif.Sony2010e.LensType2 Short 1 1024\n" + ,"" + ,"" + ,"" + ,"Exif.Sony2010e.LensType2 Short 1 1024\n" + ] + stderr = [""]*len(commands) + retval = [ 0,0,0,0,0,1,0,0] diff --git a/tests/suite.conf b/tests/suite.conf index d4fb4924ec..e5c48c21fb 100644 --- a/tests/suite.conf +++ b/tests/suite.conf @@ -1,5 +1,5 @@ [General] -timeout: 2 +timeout: 20.0 memcheck: ${ENV:valgrind} [ENV]