#841: Do not read past the end of the data stream (file), added test case.

v0.27.3
Andreas Huggel 13 years ago
parent 856b72530d
commit 9b7f1de5c0

@ -118,6 +118,7 @@ namespace Exiv2 {
}
clearMetadata();
const long imgSize = io_->size();
DataBuf cheaderBuf(8); // Chunk header size : 4 bytes (data size) + 4 bytes (chunk type).
while(!io_->eof())
@ -134,7 +135,8 @@ namespace Exiv2 {
// Decode chunk data length.
uint32_t dataOffset = Exiv2::getULong(cheaderBuf.pData_, Exiv2::bigEndian);
if (dataOffset > 0x7FFFFFFF) throw Exiv2::Error(14);
long pos = io_->tell();
if (pos == -1 || static_cast<long>(dataOffset) > imgSize - pos) throw Exiv2::Error(14);
// Perform a chunk triage for item that we need.

@ -248,6 +248,13 @@ else
printf "($num skipped) " >&3
fi
num=841
filename=exiv2-bug$num.png
printf "$num " >&3
echo '------>' Bug $num '<-------' >&2
cp -f ../data/$filename $filename
$bin/exiv2 $filename
) 3>&1 > $results 2>&1
printf "\n"

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Loading…
Cancel
Save