From 58c5ffdedca2f8bf720c083682987fac3abdda1d Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Fri, 22 Apr 2016 14:11:09 +0000 Subject: [PATCH] #1108. Fixed issue with printing short strings which are stored in the directory offset field. --- src/tiffimage.cpp | 7 ++++--- test/data/bugfixes-test.out | Bin 1900959 -> 1901156 bytes 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp index 2bf59d9e..34c5c04b 100644 --- a/src/tiffimage.cpp +++ b/src/tiffimage.cpp @@ -414,6 +414,7 @@ namespace Exiv2 { return type == Exiv2::asciiString || type == Exiv2::unsignedByte || type == Exiv2::signedByte + || type == Exiv2::undefined ; } static bool isShortType(uint16_t type) { @@ -524,13 +525,13 @@ namespace Exiv2 { // if ( offset > io.size() ) offset = 0; // Denial of service? DataBuf buf(MIN(size*kount + pad,48)); // allocate a buffer - if ( isStringType(type) || count*size > 4 ) { // data is in the directory => read into buffer + if ( (isStringType(type) && count*size > 4) || count*size > 4 ) { // read into buffer size_t restore = io.tell(); // save io.seek(offset,BasicIo::beg); // position io.read(buf.pData_,kount*size);// read io.seek(restore,BasicIo::beg); // restore - } else { // move data from directory to the buffer - std::memcpy(buf.pData_,dir.pData_+8,12); + } else { // move data from directory into buffer + std::memcpy(buf.pData_,dir.pData_+8,4); } uint32_t Offset = isLongType(type) ? byteSwap4(buf,0,bSwap) : 0 ; diff --git a/test/data/bugfixes-test.out b/test/data/bugfixes-test.out index a5050c89cac1f4674c11eba7f96277f3f92ce5f1..8f31222b4fe464be63b39e95fc0f1a94fe89fce8 100644 GIT binary patch delta 543 zcmYk2O-mb56o#2GR`bzRW2&_tWGbj7(aW8Q&X__eQHw^RpvKVHO@u}X+6lz?S%QjZ zC0!Jx++`QyRyU=$;2%)%SBQVWrJLZrcN9E}^W4w#zUTZotlnaEA2rmm0e#qrFR%%l z(T@QPVhCSi7++xvwqgX^Fp96S9Xs$1cH&#?`U@A`VQ0iK9cS1{8VPe~m|u0nK-2Nv zyC|#oLdHj}1m#nG@Lp>mgz!o~T_8|s~&8hjZbXuGo zAA~#E?-=BDO4(fua*|VVk0*jYYEsJY;}Fp`!h!^H0!sposw)3a;4=D5bb6Y2s&RGi ziBi5l1|d!S{5dWQ@SAb?+7N?r?wsO>!zK1bMj98%0Jg5UGKRfIDs+q(i;A-l5zN4`N(dNNaT z%Yx*)TdmAZj2d6^i-z3GkPEM5!m?OvLMYF!!MR@z-oL2^FMKX+J`KLM1=q?~W>*f* YW~Yy=3wlPfKj5D<5~!*E3pMzJ4;f;V_5c6? delta 318 zcmXxe&q@MO7zJ?djLtNrmS$P{ArfR#GNlbgtAWB@wKAh3EMcmJn?Ne)4?<_v1N1?g zo}e~~cM*ZKQiz@+dVqEmAI)wq-1!W+EMwtMghS_K~?q(w3py|kqqt}(1wg3 z(v*;Hg<6_!+Zh%f6?@q3<4HmKkLX!&<5^snVatty41j{fstc^t}7ky`Yco bj?KYK^{@-Ck2eJwyP~Gx&uhi$8*=dvV1Z;V