Skip to content

fix: return error on packet length overflow in TransportLayerCC and CCFeedbackReport - #235

Open
AdamMagued wants to merge 1 commit into
pion:mainfrom
AdamMagued:fix/issue-234-marshal-overflow-packet-too-large
Open

AdamMagued wants to merge 1 commit into
pion:mainfrom
AdamMagued:fix/issue-234-marshal-overflow-packet-too-large

Conversation

@AdamMagued

Copy link
Copy Markdown

Fixes #234

Problem

In TransportLayerCC and CCFeedbackReport, Marshal calculates the packet length in 32-bit words and casts it to a uint16. When a packet contains a large number of deltas or feedback metric blocks such that the payload exceeds math.MaxUint16 words, the integer wraps around. This causes the allocated buffer to be undersized, triggering a panic: runtime error: slice bounds out of range during marshaling.

Solution

  • Added overflow checks in TransportLayerCC.Marshal / MarshalTo and CCFeedbackReport.Marshal / MarshalTo returning errPacketTooLarge when the packet size cannot fit within the RTCP length field.
  • Added unit tests in transport_layer_cc_test.go and rfc8888_test.go verifying that oversized packets return an error gracefully rather than panicking.

Verified via container sandbox test suite.

Return errPacketTooLarge when TransportLayerCC or CCFeedbackReport
length overflows the uint16 RTCP header length limit. Also update
TransportLayerCC.packetLen to return an int to prevent wrapping.

Signed-off-by: Adam Magued <adamismailmageud@gmail.com>
@AdamMagued
AdamMagued force-pushed the fix/issue-234-marshal-overflow-packet-too-large branch from b51175d to 767fa86 Compare October 17, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

TransportLayerCC / CCFeedbackReport: Marshal panics on packets over the uint16 length limit

1 participant