Skip to content

fix(dpx): fix heap overflow in 1-channel 10-bit filled scanline swap#5298

Open
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-dpx1bit
Open

fix(dpx): fix heap overflow in 1-channel 10-bit filled scanline swap#5298
lgritz wants to merge 1 commit into
AcademySoftwareFoundation:mainfrom
lgritz:lg-dpx1bit

Conversation

@lgritz

@lgritz lgritz commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant