From dff941ad7f203cacbb6a8ad0a4e86e2642d14d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Walenciak?= Date: Mon, 18 Sep 2017 22:32:52 +0200 Subject: [PATCH] Do not print offset when it is used as tag's value --- src/image.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/image.cpp b/src/image.cpp index 9a1687e9..830caa02 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -370,7 +370,9 @@ namespace Exiv2 { // if ( offset > io.size() ) offset = 0; // Denial of service? DataBuf buf(size*count + pad+20); // allocate a buffer std::memcpy(buf.pData_,dir.pData_+8,4); // copy dir[8:11] into buffer (short strings) - if ( count*size > 4 ) { // read into buffer + const bool offsetIsPointer = count*size > 4; + + if ( offsetIsPointer ) { // read into buffer size_t restore = io.tell(); // save io.seek(offset,BasicIo::beg); // position io.read(buf.pData_,count*size);// read @@ -378,10 +380,14 @@ namespace Exiv2 { } if ( bPrint ) { - uint32_t address = start + 2 + i*12 ; + const uint32_t address = start + 2 + i*12 ; + const std::string offsetString = offsetIsPointer? + Internal::stringFormat("%10u", offset): + ""; + out << Internal::indent(depth) - << Internal::stringFormat("%8u | %#06x %-25s |%10s |%9u |%10u | " - ,address,tag,tagName(tag).c_str(),typeName(type),count,offset); + << Internal::stringFormat("%8u | %#06x %-25s |%10s |%9u |%10s | " + ,address,tag,tagName(tag).c_str(),typeName(type),count,offsetString.c_str()); if ( isShortType(type) ){ for ( size_t k = 0 ; k < kount ; k++ ) { out << sp << byteSwap2(buf,k*size,bSwap);