gainmapmath: fix OOB reads in encoder pixel processing on odd-dimension images#392
Open
jortles wants to merge 1 commit into
Open
gainmapmath: fix OOB reads in encoder pixel processing on odd-dimension images#392jortles wants to merge 1 commit into
jortles wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…on images Two heap-buffer-overflow reads exist in internal encoder pixel-processing functions when image dimensions are odd: 1. getP010Pixel: The interleaved UV chroma index computation `(x & ~0x1) + 1` overflows the chroma row when width is odd and x is the last pixel. Fix: clamp chroma_x so the V sample index stays within the allocated chroma plane. 2. convert_raw_input_to_ycbcr: The 2x2 block loop accesses row i+1 and column j+1 unconditionally, reading past the source buffer when height or width is odd. Fix: change loop bounds from `i < h` to `i + 1 < h` (and likewise for j/w) so incomplete trailing blocks are skipped. The public encoder API (uhdr_enc_set_raw_image) already rejects odd dimensions for P010 and YCbCr420 formats, so these are defense-in-depth fixes for internal callers that bypass that validation. Found by: AFL++ fuzzing with custom pixel-format harness Signed-off-by: Anthony Hurtado <amhurtado@pm.me>
f4110c3 to
a4368db
Compare
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.
Summary
getP010PixelUV overflow on odd width: The interleaved chroma index(x & ~0x1) + 1reads 1 element past the chroma plane when image width is odd andxis the last pixel in a row. Fix: clampchroma_xso the V sample stays in bounds.convert_raw_input_to_ycbcrrow/column overflow on odd height/width: The 2×2 block loops accessrow[i+1]andcol[j+1]unconditionally, overflowing when height or width is odd. Fix: change loop bounds fromi < htoi + 1 < h(andj + 1 < w) so incomplete trailing blocks are skipped. Applied to both the RGBA1010102 and RGBA8888 paths.The public encoder API (
uhdr_enc_set_raw_image) already rejects odd dimensions for P010/YCbCr420, so these are defense-in-depth fixes for internal callers that bypass that validation.Found by AFL++ fuzzing with a custom pixel-format harness.
Test plan
🤖 Generated with Claude Code