Reject truncated page headers in ogg_stream_pagein - #107
Open
samuelgirmametaferia wants to merge 1 commit into
Open
Reject truncated page headers in ogg_stream_pagein#107samuelgirmametaferia wants to merge 1 commit into
samuelgirmametaferia wants to merge 1 commit into
Conversation
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.
Summary
Reject truncated page headers in
ogg_stream_pagein()before reading fixed header fields or the lacing table.ogg_stream_pagein()currently calls helpers such asogg_page_version(),ogg_page_granulepos(), andogg_page_serialno(), and readsheader[26], before checkingog->header_len. A caller that passes a directly constructed or mutatedogg_pagewith a short header can therefore cause an out-of-bounds read before the function reaches its existing stream/page checks.A one-byte header reproduces this under AddressSanitizer as a stack-buffer-overflow in
ogg_page_version(), called fromogg_stream_pagein().The change validates the 27-byte fixed header first, reads the segment count only after that check, and then verifies that the complete lacing table is present before parsing any page fields. The existing
-1error convention is used for malformed input.Validation
test_bitwise: PASStest_framing: PASS, including new short-fixed-header and truncated-lacing-table casesmain: one-byte reproducer triggers AddressSanitizer stack-buffer-overflow inogg_page_version()-1without an ASan/UBSan findinggit diff --check: PASSI also checked the current open
src/framing.cpull requests. #102 handles an inconsistent/negative body length, #105 handles sync byte counts, and #91/#94 touch unrelated code; none validatesogg_stream_pagein()header length before these reads.