Merge pull request #230 from D4N/fix_170

Fix for #170
This commit is contained in:
D4N 2018-02-22 17:16:09 +01:00 committed by GitHub
commit 28fa146d97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 1 deletions

View File

@ -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);

View File

@ -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))
{

BIN
test/data/issue_170_poc Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

View File

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
import system_tests
class decodeIHDRChunkOutOfBoundsRead(system_tests.Case):
url = "https://github.com/Exiv2/exiv2/issues/170"
filename = "{data_path}/issue_170_poc"
commands = ["{exiv2} " + filename]
stdout = [""]
stderr = ["""{exiv2_exception_msg} """ + filename + """:
{kerFailedToReadImageData}
"""]
retval = [1]