Skip to content

Commit

Permalink
improve bad count detection in huf decompress
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman committed Feb 4, 2020
1 parent 801272c commit 43cd3ad
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions OpenEXR/IlmImf/ImfHuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,10 @@ hufUncompress (const char compressed[],
unsigned short raw[],
int nRaw)
{
if (nCompressed == 0)
//
// nead at least 20 bytes for header
//
if (nCompressed < 20 )
{
if (nRaw != 0)
notEnoughData();
Expand All @@ -1072,7 +1075,8 @@ hufUncompress (const char compressed[],

if ( ptr + (nBits+7 )/8 > compressed+nCompressed)
{
throw Iex::InputExc("invalid bit count for data size in Huf data");
notEnoughData();
return;
}

//
Expand Down

0 comments on commit 43cd3ad

Please sign in to comment.