Skip to content

obu: refuse a frame size override past the sequence header's maximum - #1513

Open
josefguenther wants to merge 1 commit into
memorysafety:mainfrom
josefguenther:fix/frame-size-override-bound
Open

josefguenther wants to merge 1 commit into
memorysafety:mainfrom
josefguenther:fix/frame-size-override-bound

Conversation

@josefguenther

Copy link
Copy Markdown

The AV1 spec (§5.9.5) requires a frame's width and height to stay within the sequence header's maximums. When a frame overrides its size, rav1d reads both and never compares them with those maximums, so a frame header can state any shape up to 2^16 on each axis. Only the frame size limit, an area, bounds it after that. libaom refuses such a frame ("Frame dimensions are larger than the maximum values").

It matters to a caller that budgets memory from the sequence header or the container's extent. Pictures are padded to 128 rows and columns, so a thin frame of an allowed area (65,536 x 1 under a 256 x 256 maximum) allocates a picture about 128 times what the sequence header implies, shown or hidden, and a hidden one stays in the reference slots.

Repro over a constructed stream, in the new tests: a non-reduced sequence header with a maximum of 64 x 64, then a key frame header overriding its size.

frame header states main this PR
64 x 64 Ok Ok
64 x 1 Ok Ok
65 x 64 Ok OutOfRange
64 x 65 Ok OutOfRange
256 x 1 Ok OutOfRange
1 x 256 Ok OutOfRange

This returns the same error as the frame size limit check. A frame that takes its size from a reference needs no check of its own, because the reference was decoded under the same sequence header (a changed sequence header drops the references). The dav1d-test-data suite passes unchanged.

dav1d has the same gap, if you'd rather it went there first.

Written with AI assistance (Claude Code); I have reviewed the change.

§5.9.5 requires `frame_width_minus_1 <= max_frame_width_minus_1` and the same
for the height. `parse_frame_size` read both fields and compared neither, so a
frame header could state any shape its bits allow, bounded after that only by
`frame_size_limit`'s area. libaom refuses such a frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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