|
|
@ -317,28 +317,29 @@ namespace Exiv2 {
|
|
|
|
|
|
|
|
|
|
|
|
if( bDump ) {
|
|
|
|
if( bDump ) {
|
|
|
|
DataBuf dataBuf;
|
|
|
|
DataBuf dataBuf;
|
|
|
|
auto data = new byte[dataOffset + 1];
|
|
|
|
enforce(static_cast<uint64_t>(dataOffset) < static_cast<unsigned long>(std::numeric_limits<long>::max()), kerFailedToReadImageData);
|
|
|
|
data[dataOffset] = 0;
|
|
|
|
DataBuf data(static_cast<long>(dataOffset) + 1);
|
|
|
|
bufRead = io_->read(data,dataOffset);
|
|
|
|
data.pData_[dataOffset] = 0;
|
|
|
|
|
|
|
|
bufRead = io_->read(data.pData_, static_cast<long>(dataOffset));
|
|
|
|
enforce(bufRead == static_cast<long>(dataOffset), kerFailedToReadImageData);
|
|
|
|
enforce(bufRead == static_cast<long>(dataOffset), kerFailedToReadImageData);
|
|
|
|
io_->seek(restore, BasicIo::beg);
|
|
|
|
io_->seek(restore, BasicIo::beg);
|
|
|
|
uint32_t name_l = static_cast<uint32_t>(std::strlen(reinterpret_cast<const char*>(data))) +
|
|
|
|
size_t name_l = std::strlen(reinterpret_cast<const char*>(data.pData_)) +
|
|
|
|
1; // leading string length
|
|
|
|
1; // leading string length
|
|
|
|
enforce(name_l <= dataOffset, kerCorruptedMetadata);
|
|
|
|
enforce(name_l < dataOffset, kerCorruptedMetadata);
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t start = name_l;
|
|
|
|
uint32_t start = static_cast<uint32_t>(name_l);
|
|
|
|
bool bLF = false;
|
|
|
|
bool bLF = false;
|
|
|
|
|
|
|
|
|
|
|
|
// decode the chunk
|
|
|
|
// decode the chunk
|
|
|
|
bool bGood = false;
|
|
|
|
bool bGood = false;
|
|
|
|
if ( tEXt ) {
|
|
|
|
if ( tEXt ) {
|
|
|
|
bGood = tEXtToDataBuf(data+name_l,dataOffset-name_l,dataBuf);
|
|
|
|
bGood = tEXtToDataBuf(data.pData_ + name_l, static_cast<unsigned long>(dataOffset - name_l), dataBuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( zTXt || iCCP ) {
|
|
|
|
if ( zTXt || iCCP ) {
|
|
|
|
bGood = zlibToDataBuf(data+name_l+1,dataOffset-name_l-1,dataBuf); // +1 = 'compressed' flag
|
|
|
|
bGood = zlibToDataBuf(data.pData_ + name_l + 1, static_cast<unsigned long>(dataOffset - name_l - 1), dataBuf); // +1 = 'compressed' flag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( iTXt ) {
|
|
|
|
if ( iTXt ) {
|
|
|
|
bGood = (start+3) < dataOffset ; // good if not a nul chunk
|
|
|
|
bGood = (3 <= dataOffset) && (start < dataOffset-3); // good if not a nul chunk
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( eXIf ) {
|
|
|
|
if ( eXIf ) {
|
|
|
|
bGood = true ;// eXIf requires no pre-processing)
|
|
|
|
bGood = true ;// eXIf requires no pre-processing)
|
|
|
@ -347,8 +348,8 @@ namespace Exiv2 {
|
|
|
|
// format is content dependent
|
|
|
|
// format is content dependent
|
|
|
|
if ( bGood ) {
|
|
|
|
if ( bGood ) {
|
|
|
|
if ( bXMP ) {
|
|
|
|
if ( bXMP ) {
|
|
|
|
while (start < dataOffset && !data[start]) start++; // skip leading nul bytes
|
|
|
|
while (start < dataOffset && !data.pData_[start]) start++; // skip leading nul bytes
|
|
|
|
out << data+start; // output the xmp
|
|
|
|
out << data.pData_ + start; // output the xmp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( bExif || bIptc ) {
|
|
|
|
if ( bExif || bIptc ) {
|
|
|
@ -389,13 +390,12 @@ namespace Exiv2 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( eXIf && option == kpsRecursive ) {
|
|
|
|
if ( eXIf && option == kpsRecursive ) {
|
|
|
|
// create memio object with the data, then print the structure
|
|
|
|
// create memio object with the data, then print the structure
|
|
|
|
BasicIo::UniquePtr p = BasicIo::UniquePtr(new MemIo(data,dataOffset));
|
|
|
|
BasicIo::UniquePtr p = BasicIo::UniquePtr(new MemIo(data.pData_, dataOffset));
|
|
|
|
printTiffStructure(*p,out,option,depth);
|
|
|
|
printTiffStructure(*p,out,option,depth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( bLF ) out << std::endl;
|
|
|
|
if ( bLF ) out << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete[] data;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
io_->seek(dataOffset+4, BasicIo::cur);// jump past checksum
|
|
|
|
io_->seek(dataOffset+4, BasicIo::cur);// jump past checksum
|
|
|
|
if (io_->error()) throw Error(kerFailedToReadImageData);
|
|
|
|
if (io_->error()) throw Error(kerFailedToReadImageData);
|
|
|
|