fix(dpx): fix heap overflow in 1-channel 10-bit filled scanline swap#5298
Open
lgritz wants to merge 1 commit into
Open
fix(dpx): fix heap overflow in 1-channel 10-bit filled scanline swap#5298lgritz wants to merge 1 commit into
lgritz wants to merge 1 commit into
Conversation
Read10bitFilled() unpacks a scanline of 10-bit "filled" (Method A/B) samples backwards, and for 1-channel images applies a work-around that swaps the first and third datum of each group of 3 packed samples (so column order comes out right). The swap didn't check that a full group of 3 remained in bounds: whenever the scanline's datum count isn't a multiple of 3, the last (partial) group has only 1 or 2 real datums, and obuf[count + 2] reaches past the end of the caller-owned scanline buffer -- both reading and writing one sample out of bounds. Guard the swap so it only fires when a complete group of 3 remains. Add a regression test in testsuite/dpx using a crafted 1-channel, 10-bit, "Filled method A" DPX subimage (width 80, not a multiple of 3) that reproduces the overflow under ASan prior to this fix. Assisted-by: Claude Code / Sonnet 5 Signed-off-by: Larry Gritz <lg@larrygritz.com>
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.
Read10bitFilled() unpacks a scanline of 10-bit "filled" (Method A/B) samples backwards, and for 1-channel images applies a workaround that swaps the first and third datum of each group of 3 packed samples (so column order comes out right). The swap didn't check that a full group of 3 remained in bounds. Guard the swap so it only fires when a complete group of 3 remains.
Add a regression test in testsuite/dpx.
Assisted-by: Claude Code / Sonnet 5