8000 framing: validate page lengths before decomposition by mcc0nnell · Pull Request #112 · xiph/ogg · GitHub
[go: up one dir, main page]

Skip to content

framing: validate page lengths before decomposition - #112

Open
mcc0nnell wants to merge 2 commits into
xiph:mainfrom
mcc0nnell:patch-rewards/validate-page-lengths
Open

mcc0nnell wants to merge 2 commits into
xiph:mainfrom
mcc0nnell:patch-rewards/validate-page-lengths

Conversation

@mcc0nnell
Copy link
Copy Markdown

Summary

Validate ogg_page header/body lengths before ogg_stream_pagein() reads fixed header fields or decomposes the lacing table.

Details

Two malformed public ogg_page inputs reproduce memory-safety failures on current main (06a5e026):

  • a one-byte header with header_len = 1 reaches ogg_page_version() and ASan reports a stack-buffer-overflow read;
  • a page with body_len = 0 but one lacing value of 255 drives bodysize negative while skipping a continued packet, then reaches memcpy() with a negative size; ASan reports negative-size-param.

This change rejects null/short page headers, negative body lengths, truncated segment tables, body lengths that do not match the lacing table, and a nonzero body length with a null body pointer.

The built-in framing self-test covers the short-header and lacing/body mismatch cases.

Validation

  • test_framing under Clang ASan + UBSan: pass
  • standalone sanitizer repros fail on the base revision and return -1 with this patch
  • strict C89 compile with -Wall -Wextra -Werror: pass

Boundary note: pages produced through the normal sync parser already carry consistent lengths. This patch hardens the public ogg_stream_pagein() boundary for callers that supply an ogg_page directly.

Signed-off-by: Robert McConnell robert@mcc0nnell.org

Signed-off-by: Robert McConnell <robert@mcc0nnell.org>
Signed-off-by: Robert McConnell <robert@mcc0nnell.org>
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

0