#841: Additional check to prevent issues with the sign when casting uint32_t to long.

This commit is contained in:
Andreas Huggel 2012-08-31 04:31:05 +00:00
parent 9b7f1de5c0
commit 60560ff051

View File

@ -136,7 +136,9 @@ namespace Exiv2 {
// Decode chunk data length.
uint32_t dataOffset = Exiv2::getULong(cheaderBuf.pData_, Exiv2::bigEndian);
long pos = io_->tell();
if (pos == -1 || static_cast<long>(dataOffset) > imgSize - pos) throw Exiv2::Error(14);
if ( pos == -1
|| dataOffset > uint32_t(0x7FFFFFFF)
|| static_cast<long>(dataOffset) > imgSize - pos) throw Exiv2::Error(14);
// Perform a chunk triage for item that we need.