Skip to content

Commit

Permalink
Merge pull request #1476 from Exiv2/fix_1471_sony2010_0.27
Browse files Browse the repository at this point in the history
Fix 1471 sony2010 0.27
  • Loading branch information
clanmills authored Feb 19, 2021
2 parents c3f12c0 + d455f47 commit c6de72f
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 10 deletions.
23 changes: 14 additions & 9 deletions src/tiffcomposite_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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_) {
Expand Down Expand Up @@ -1433,16 +1434,20 @@ namespace Exiv2 {
uint16_t lastTag = static_cast<uint16_t>(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<uint32_t>(mio.size()), pRoot_);
}
if (buf.size_ > 0) {
ioWrapper.write(buf.pData_, buf.size_);
}
else {
ioWrapper.write(mio.mmap(), static_cast<uint32_t>(mio.size()));
// Select sonyTagEncipher
CryptFct cryptFct = cfg()->cryptFct_;
if ( cryptFct == sonyTagDecipher ) {
cryptFct = sonyTagEncipher;
}
DataBuf buf = cryptFct(tag(), mio.mmap(), static_cast<uint32_t>(mio.size()), pRoot_);
if ( buf.size_) {
mio.seek(0,Exiv2::FileIo::beg);
mio.write(buf.pData_, buf.size_);
}
}
ioWrapper.write(mio.mmap(), static_cast<uint32_t>(mio.size()));

return idx;
} // TiffBinaryArray::doWrite
Expand Down
Binary file added test/data/test_issue_1471.exv
Binary file not shown.
Binary file added test/data/test_issue_1472.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions tests/bugfixes/github/test_issue_1471.py
Original file line number Diff line number Diff line change
@@ -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)
29 changes: 29 additions & 0 deletions tests/bugfixes/github/test_issue_1472.py
Original file line number Diff line number Diff line change
@@ -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]
2 changes: 1 addition & 1 deletion tests/suite.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[General]
timeout: 2
timeout: 20.0
memcheck: ${ENV:valgrind}

[ENV]
Expand Down

0 comments on commit c6de72f

Please sign in to comment.