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 and cary-ilm committed Mar 5, 2023
1 parent 420da6a commit 8984b04
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/OpenEXR/ImfScanLineInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,8 +1102,10 @@ void 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 8984b04

Please sign in to comment.