From b2e00c2d5384552bf11ad56e68b340fb0e5bbff1 Mon Sep 17 00:00:00 2001 From: Andreas Huggel Date: Thu, 8 Feb 2007 15:29:42 +0000 Subject: [PATCH] Improved RAF support to read thumbnail data which are outside of the Exif block. --- src/rafimage.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/rafimage.cpp b/src/rafimage.cpp index f1bf758b..7dafc7fe 100644 --- a/src/rafimage.cpp +++ b/src/rafimage.cpp @@ -89,20 +89,13 @@ namespace Exiv2 { if (io_->error() || io_->eof()) throw Error(14); throw Error(3, "RAF"); } - if (io_->seek(84, BasicIo::beg) != 0) throw Error(14); - byte tmp[4]; - io_->read(tmp, 4); - if (io_->error() || io_->eof()) throw Error(14); - uint32_t const pos = getULong(tmp, bigEndian) + 4; - if (io_->seek(pos, BasicIo::beg) != 0) throw Error(14); - io_->read(tmp, 2); - if (io_->error() || io_->eof()) throw Error(14); - DataBuf buf(getUShort(tmp, bigEndian) - 10); - if (io_->seek(pos + 8, BasicIo::beg) != 0) throw Error(14); - io_->read(buf.pData_, buf.size_); - if (io_->error() || io_->eof()) throw Error(14); + byte const* pData = io_->mmap(); + long size = io_->size(); + if (size < 84 + 4) throw Error(14); // includes the test for -1 + uint32_t const start = getULong(pData + 84, bigEndian) + 12; + if (static_cast(size) < start) throw Error(14); clearMetadata(); - TiffParser::decode(this, buf.pData_, buf.size_, + TiffParser::decode(this, pData + start, size - start, TiffCreator::create, TiffDecoder::findDecoder); } // RafImage::readMetadata