Skip to content

framing: reject invalid sync buffer lengths - #110

Open
mcc0nnell wants to merge 1 commit into
xiph:mainfrom
mcc0nnell:patch-rewards/reject-negative-sync-lengths
Open

mcc0nnell wants to merge 1 commit into
xiph:mainfrom
mcc0nnell:patch-rewards/reject-negative-sync-lengths

Conversation

@mcc0nnell

Copy link
Copy Markdown

Summary

Reject invalid negative lengths in the sync buffering API and avoid signed overflow in the ogg_sync_wrote() bounds check.

Details

ogg_sync_wrote() currently accepts a negative bytes value. That can move oy->fill backwards, leaving the sync state pointing before the start of its allocated buffer. A subsequent buffer operation can then access memory before the allocation. I reproduced this as an ASan heap-buffer-overflow.

This change:

  • rejects negative sizes in ogg_sync_buffer();
  • rejects negative byte counts in ogg_sync_wrote();
  • rewrites the upper-bound check as bytes > storage - fill to avoid signed overflow in fill + bytes;
  • adds regression coverage for negative values and LONG_MAX.

Testing

  • test_framing
  • test_bitwise
  • ASan/UBSan build and regression run

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

Signed-off-by: Robert McConnell <robert@mcc0nnell.org>
@mcc0nnell
mcc0nnell force-pushed the patch-rewards/reject-negative-sync-lengths branch from 1bada87 to 3785dcc Compare September 14, 2026 05:42
@mcc0nnell
mcc0nnell changed the base branch from master to main September 14, 2026 05:42
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