Fix box.length == to use bigEndian decode! Fix toAscii() to emit on ascii 32-127 bytes.

main
clanmills 4 years ago
parent a0e63615e6
commit ee4d14340a

@ -107,7 +107,10 @@ namespace Exiv2
std::string result; std::string result;
bool bBigEndian = isBigEndianPlatform(); bool bBigEndian = isBigEndianPlatform();
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
result += p[bBigEndian ? i : (3 - i)]; char c = p[bBigEndian ? i : (3 - i)];
result += (32<=c && c<=127) ? c // only allow 7-bit printable ascii
: c==0 ? '_' // show 0 and _
: '.' ; // others .
} }
return result; return result;
} }
@ -207,11 +210,13 @@ namespace Exiv2
if (box.length == 1) { if (box.length == 1) {
DataBuf data(8); DataBuf data(8);
io_->read(data.pData_, data.size_); io_->read(data.pData_, data.size_);
result = address + (long)getULongLong(data.pData_, littleEndian); result = address + (long)getULongLong(data.pData_, bigEndian);
// sanity check // sanity check
if (result < 0 || result > (long)io_->size()) { if (result < 8 || result > (long)io_->size()) {
result = (long)io_->size(); result = (long)io_->size();
box.length = result - address; box.length = result - address;
} else {
box.length = io_->size() - address - 8;
} }
if ( bTrace ) { if ( bTrace ) {
out << Internal::stringFormat(" (%lu)", result); out << Internal::stringFormat(" (%lu)", result);
@ -437,8 +442,7 @@ namespace Exiv2
if ( bLF&& bTrace) out << std::endl; if ( bLF&& bTrace) out << std::endl;
// return address of next box // return address of next box
if (box.length != 1) result = static_cast<long>(address + box.length);
result = static_cast<long>(address + box.length);
return result; return result;
} }

Loading…
Cancel
Save