Repository navigation
Conversation
write_header() computes max_sz - HEADER_SZ before checking anything, so a chunk smaller than the 6 byte header (a single HALF or FLOAT sample, for example a 1x1 image) wraps the size to near SIZE_MAX and buffer + max_sz overflows the pointer. UBSan flags it, and it only ends up throwing range_error today because the wrapped end pointer happens to land before cur. Throw range_error up front when max_sz < HEADER_SZ. The encoder already catches that and stores the chunk uncompressed, so the output does not change. Signed-off-by: Armaan Sandhu <armaan.sandhu0504@gmail.com>
Member
|
Thanks for the fix. The failing mingw32 CI check is unrelated and will be resolved by #2840. Waiting on @palemieux's review to approve and merge. |
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.
small one in the HTJ2K header writer. When a chunk is smaller than the 6 byte header, like a 1x1 image with one half or float channel,
write_headersubstracts the header size frommax_szfirst and wraps it, sobuffer + max_szoverflows. The encoding fuzzer hit this too.Repro: write a 1x1 HTJ2K256 scanline file through the Core API in a UBSan build:
it worked by luck before, the wrapped end pointer made the next push throw
range_erroranyway. The fix just throws that same error before the subtraction, so nothing changes in the output. Added the small sizes totestHTHeaderBounds, which fails under UBSan without the fix and passes with it. Rest of the OpenEXRCore tests pass under UBSan apart from testAttrChlists/testAttrLists, which fail on main too (they pass -1 as an enum on purpose).