#1143. Partial solution. I have suppressed the warning and allocated memory for Exif.Sony1.Preview. So now the size is revealed to the user. However: for reasons documented in the code, I am unable to locate the image in the source file and copy it into the metadata.

v0.27.3
Robin Mills 10 years ago
parent 77ae982cd4
commit 0798b95b50

@ -1489,12 +1489,17 @@ namespace Exiv2 {
return; return;
} }
p += 4; p += 4;
uint32_t isize= 0; // size of Exif.Sony1.PreviewImage
uint32_t size = typeSize * count; uint32_t size = typeSize * count;
int32_t offset = getLong(p, byteOrder()); int32_t offset = getLong(p, byteOrder());
byte* pData = p; byte* pData = p;
if ( size > 4 if ( size > 4
&& ( baseOffset() + offset >= size_ && ( baseOffset() + offset >= size_
|| static_cast<int32_t>(baseOffset()) + offset <= 0)) { || static_cast<int32_t>(baseOffset()) + offset <= 0)) {
// #1143
if ( object->tag() == 0x2001 && std::string(groupName(object->group())) == "Sony1" ) {
isize=size;
} else {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
EXV_ERROR << "Offset of directory " << groupName(object->group()) EXV_ERROR << "Offset of directory " << groupName(object->group())
<< ", entry 0x" << std::setw(4) << ", entry 0x" << std::setw(4)
@ -1504,6 +1509,7 @@ namespace Exiv2 {
<< std::setfill('0') << std::hex << offset << std::setfill('0') << std::hex << offset
<< "; truncating the entry\n"; << "; truncating the entry\n";
#endif #endif
}
size = 0; size = 0;
} }
if (size > 4) { if (size > 4) {
@ -1528,7 +1534,17 @@ namespace Exiv2 {
} }
Value::AutoPtr v = Value::create(typeId); Value::AutoPtr v = Value::create(typeId);
assert(v.get()); assert(v.get());
v->read(pData, size, byteOrder()); if ( !isize ) {
v->read(pData, size, byteOrder());
} else {
// #1143 Write a "hollow" buffer for the preview image
// Sadly: we don't know the exact location of the image in the source (it's near offset)
// And neither TiffReader nor TiffEntryBase have access to the BasicIo object being processed
byte* buffer = (byte*) ::malloc(isize);
::memset(buffer,isize,0);
v->read(buffer,isize, byteOrder());
::free(buffer);
}
object->setValue(v); object->setValue(v);
object->setData(pData, size); object->setData(pData, size);

Loading…
Cancel
Save