Repository navigation
Conversation
…gmg-pr4v)
The deep scanline and tiled readers computed the per-line offset into
the sample-count table with 32-bit int arithmetic:
const int32_t* counts = decoder.sample_count_table + y * cinfo.width;
For a sufficiently large chunk/tile, y * cinfo.width can overflow a
signed 32-bit int and wrap negative, producing a pointer before the
allocated table and an out-of-bounds read in the following memcpy.
Promote the multiplication to int64_t, matching the already-safe
sibling code paths (ImfDeepScanLineInputFile.cpp:942,
ImfDeepTiledInputFile.cpp:1147).
In practice the deep scanline path is not reachable: deep data only
permits compressions with one line per chunk (NONE/RLE/ZIPS/ZSTD),
enforced on read, so cinfo.height is 1 and y is always 0. The deep
tiled path is reachable only for tiles whose width*height exceeds
INT_MAX, which also requires the >8 GB sample-count allocation to
succeed first. This change is defense-in-depth and restores
consistency with the 64-bit-safe fill paths.
Addresses https://github.com/AcademySoftwareFoundation/openexr/security/advisories/GHSA-54mf-6gmg-pr4v
Assisted-by: Copilot / Claude Opus 4.8
Signed-off-by: Cary Phillips <seabeepea@gmail.com>
peterhillman
approved these changes
Nov 11, 2026
peterhillman
left a comment
Collaborator
There was a problem hiding this comment.
Looks good, but do we not prefer static_cast<uint64_t>(y) instead of (uint64_t) y ?
Signed-off-by: Cary Phillips <seabeepea@gmail.com>
Member
Author
|
Yes, updated, and simplified several neighboring casts in the process. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The deep scanline and tiled readers computed the per-line offset into the sample-count table with 32-bit int arithmetic:
For a sufficiently large chunk/tile, y * cinfo.width can overflow a signed 32-bit int and wrap negative, producing a pointer before the allocated table and an out-of-bounds read in the following memcpy.
Promote the multiplication to int64_t, matching the already-safe sibling code paths (ImfDeepScanLineInputFile.cpp:942, ImfDeepTiledInputFile.cpp:1147).
In practice the deep scanline path is not reachable: deep data only permits compressions with one line per chunk (NONE/RLE/ZIPS/ZSTD), enforced on read, so cinfo.height is 1 and y is always 0. The deep tiled path is reachable only for tiles whose width*height exceeds INT_MAX, which also requires the >8 GB sample-count allocation to succeed first. This change is defense-in-depth and restores consistency with the 64-bit-safe fill paths.
Addresses https://github.com/AcademySoftwareFoundation/openexr/security/advisories/GHSA-54mf-6gmg-pr4v
Assisted-by: Copilot / Claude Opus 4.8