From 7beb4e3e0dad6f22365fd93207de1434b5d3276b Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Thu, 18 Feb 2021 16:23:28 +0000 Subject: [PATCH] fix_1471_sony2010_0.27 --- src/tiffcomposite_int.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/tiffcomposite_int.cpp b/src/tiffcomposite_int.cpp index a6bf925b..9e12ed36 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" @@ -1433,16 +1434,21 @@ namespace Exiv2 { uint16_t lastTag = static_cast(lastDef->idx_ / cfg()->tagStep()); idx += fillGap(mioWrapper, idx, lastDef->idx_ + lastDef->size(lastTag, cfg()->group_)); } - DataBuf buf; + + bool bCopyMio = true ; // MemIo mio stream contain the the "raw" data 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_) { + ioWrapper.write(buf.pData_, buf.size_); + bCopyMio=false ; + } } + if ( bCopyMio ) ioWrapper.write(mio.mmap(), static_cast(mio.size())); return idx; } // TiffBinaryArray::doWrite