Skip to content

Commit

Permalink
prevent integer overflow of lineOffsetSize (#1260)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman authored May 10, 2022
1 parent 09c29e7 commit 91c4ae1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/OpenEXR/ImfScanLineInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,9 +1151,10 @@ ScanLineInputFile::initialize (const Header& header)

_data->linesInBuffer = numLinesInBuffer (comp);

int lineOffsetSize =
(dataWindow.max.y - dataWindow.min.y + _data->linesInBuffer) /
_data->linesInBuffer;
uint64_t lineOffsetSize =
(static_cast<int64_t>(dataWindow.max.y) - static_cast<int64_t>(dataWindow.min.y) + static_cast<int64_t>(_data->linesInBuffer)) /
static_cast<int64_t>(_data->linesInBuffer);


//
// avoid allocating excessive memory due to large lineOffsets and bytesPerLine table sizes.
Expand Down

0 comments on commit 91c4ae1

Please sign in to comment.