fix(rtp): add marshal-side bounds checks for CSRC count, extension lengths, and NALU sizes#74
Open
nightness wants to merge 1 commit intowebrtc-rs:masterfrom
Open
fix(rtp): add marshal-side bounds checks for CSRC count, extension lengths, and NALU sizes#74nightness wants to merge 1 commit intowebrtc-rs:masterfrom
nightness wants to merge 1 commit intowebrtc-rs:masterfrom
Conversation
…ngths, and NALU sizes RFC 3550 §5.1: CC is a 4-bit field (max 15 CSRCs); return TooManyCSRCs error if exceeded. RFC 8285 §4.2/4.3: one-byte extension payload must be 1–16 bytes, two-byte max 255 bytes; return errors rather than silently truncating via `as u8` cast. H.264/H.265 aggregation length fields are u16; skip NALUs > 65535 bytes instead of silently truncating their length field. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5b00e71 to
da14873
Compare
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
self.csrc.len() as u8would silently truncate; now returnsError::TooManyCSRCs(n)if > 15.payload.len() as u8 - 1would wrap/truncate on 0-length or >16-byte payloads; now returnsError::OneByteHeaderExtensionPayloadTooLarge(n).payload.len() as u8silently truncated; now returnsError::TwoByteHeaderExtensionPayloadTooLarge(n).u16; oversized NALUs are now skipped rather than having their length field silently truncated.Parse-side already has bounds checks; this brings marshal-side to parity.
Test plan
cargo test -p rtc-rtp— all 99 existing tests passHeader::marshal_to()returnsErr(TooManyCSRCs(16))for a header with 16 CSRCs🤖 Generated with Claude Code