Skip to content

Commit

Permalink
Check if embedded RAF image is really a TIFF
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilos committed Jul 25, 2021
1 parent c4861fe commit be12ae6
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/rafimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,25 @@ namespace Exiv2 {
// sanity check. Does tiff lie inside the file?
enforce(Safe::add(tiffOffset, tiffLength) <= io_->size(), kerCorruptedMetadata);

DataBuf tiff(tiffLength);
if (io_->seek(tiffOffset, BasicIo::beg) != 0) throw Error(kerFailedToReadImageData);
io_->read(tiff.pData_, tiff.size_);

if (!io_->error() && !io_->eof())
// check if this really is a tiff (some older models just embed a raw bitstream)
io_->read(readBuff, 4);
io_->seek(-4, BasicIo::cur);
if (memcmp(readBuff, "\x49\x49\x2A\x00", 4) == 0 ||
memcmp(readBuff, "\x4D\x4D\x00\x2A", 4) == 0)
{
TiffParser::decode(exifData_,
iptcData_,
xmpData_,
tiff.pData_,
tiff.size_);
DataBuf tiff(tiffLength);
io_->read(tiff.pData_, tiff.size_);

if (!io_->error() && !io_->eof())
{
TiffParser::decode(exifData_,
iptcData_,
xmpData_,
tiff.pData_,
tiff.size_);
}
}
} // RafImage::readMetadata

Expand Down

0 comments on commit be12ae6

Please sign in to comment.