Skip to content

Commit

Permalink
Avoid integer overflow in calculateNumTiles()
Browse files Browse the repository at this point in the history
Signed-off-by: Cary Phillips <cary@ilm.com>
  • Loading branch information
cary-ilm committed Aug 9, 2020
1 parent ed46931 commit b10412d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion OpenEXR/IlmImf/ImfTiledMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ calculateNumTiles (int *numTiles,
{
for (int i = 0; i < numLevels; i++)
{
numTiles[i] = (levelSize (min, max, i, rmode) + size - 1) / size;
int l = levelSize (min, max, i, rmode);
if (l >= std::numeric_limits<int>::max() - size + 1)
throw IEX_NAMESPACE::ArgExc ("Invalid size.");

numTiles[i] = (l + size - 1) / size;
}
}

Expand Down

0 comments on commit b10412d

Please sign in to comment.