Skip to content

Commit

Permalink
apply AcademySoftwareFoundation#829: fix buffer overflow check in PIZ…
Browse files Browse the repository at this point in the history
… decompression

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman committed Dec 6, 2020
1 parent 6c458f7 commit 453cc69
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions OpenEXR/IlmImf/ImfFastHuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ FastHufDecoder::FastHufDecoder

for (Int64 symbol = static_cast<Int64>(minSymbol); symbol <= static_cast<Int64>(maxSymbol); symbol++)
{
if (currByte - table > numBytes)
if (currByte - table >= numBytes)
{
throw IEX_NAMESPACE::InputExc ("Error decoding Huffman table "
"(Truncated table data).");
Expand All @@ -144,7 +144,7 @@ FastHufDecoder::FastHufDecoder

if (codeLen == (Int64) LONG_ZEROCODE_RUN)
{
if (currByte - table > numBytes)
if (currByte - table >= numBytes)
{
throw IEX_NAMESPACE::InputExc ("Error decoding Huffman table "
"(Truncated table data).");
Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImf/ImfPizCompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ Xdr::read <CharPtrIO> (inPtr, (char *) &bitmap[0] + minNonZero,
int length;
Xdr::read <CharPtrIO> (inPtr, length);

if (length > inSize)
if (inPtr + length > inputEnd || length<0 )
{
throw InputExc ("Error in header for PIZ-compressed data "
"(invalid array length).");
Expand Down

0 comments on commit 453cc69

Please sign in to comment.