Added dataBuf size check before calling PngChunk::decodeIHDRChunk
- cdataBuf must be at least 8 bytes long otherwise decodeIHDRChunk reads out of bounds - pngImage::readMetadata now skips png chunks where the offset for IHDR chunks is invalid - added assertion into PngChunk::decodeIHDRChunk() to ensure dataBuf size
This commit is contained in:
parent
a1ab522eda
commit
751fba8b54
@ -64,6 +64,8 @@ namespace Exiv2 {
|
||||
int* outWidth,
|
||||
int* outHeight)
|
||||
{
|
||||
assert(data.size_ >= 8);
|
||||
|
||||
// Extract image width and height from IHDR chunk.
|
||||
|
||||
*outWidth = getLong((const byte*)data.pData_, bigEndian);
|
||||
|
||||
@ -435,7 +435,9 @@ namespace Exiv2 {
|
||||
#ifdef DEBUG
|
||||
std::cout << "Exiv2::PngImage::readMetadata: Found IHDR chunk (length: " << dataOffset << ")\n";
|
||||
#endif
|
||||
PngChunk::decodeIHDRChunk(cdataBuf, &pixelWidth_, &pixelHeight_);
|
||||
if (cdataBuf.size_ >= 8) {
|
||||
PngChunk::decodeIHDRChunk(cdataBuf, &pixelWidth_, &pixelHeight_);
|
||||
}
|
||||
}
|
||||
else if (!memcmp(cheaderBuf.pData_ + 4, "tEXt", 4))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user