Repository navigation
Fix panics in h264 Spreader.Process - #378
Merged
Merged
Conversation
Process panicked on three kinds of received packet: - A STAP-A with a single trailing byte read the 2-byte NALU size without a length check. - A FU-A fragment small enough to fit in the trailing buffer emitted nothing, then indexed the last packet of an empty slice. - An RTP header at least as large as the MTU made the payload budget zero or negative, which panicked in sliceTo or looped forever in spreadFua. The first and third now return an error. The second is a valid stream, so the fragment is buffered and Process returns no packets. Also fix two bugs in the same path: buffered trailing data was overwritten instead of appended to when a fragment emitted nothing, and a FU-A end fragment with an empty payload dereferenced a nil pointer. An empty end FU is now emitted so the end bit is not lost. Add FuzzSpreaderProcess and regression tests.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #378 +/- ##
==========================================
+ Coverage 87.48% 88.14% +0.65%
==========================================
Files 28 28
Lines 3165 3171 +6
==========================================
+ Hits 2769 2795 +26
+ Misses 396 376 -20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
JoTurk
approved these changes
Oct 13, 2026
JoTurk
left a comment
Member
There was a problem hiding this comment.
Thank you, we should move Spreader to pion/format in the next major release, since we don't use it directly in webrtc.
Member
|
@Sean-Der I realized that this had a correctness bug this is why i didn't merge it, but it avoids the panic, I'll follow up with the fix. |
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.
Spreader.Processpanicked on three kinds of received packets:The first and third now return an error. The second is a valid stream, so the fragment is buffered and Process returns no packets.
I also fixed two non-panicking bugs.
Buffered trailing data was overwritten instead of appended to when a fragment emitted nothing, and a FU-A end fragment with an empty payload dereferenced a nil pointer. An empty end FU is now emitted so the end bit is not lost.
Also added FuzzSpreaderProcess and regression tests.
The panics were found using an unreleased static analysis tool written by me. The fixes were implemented with the help of AI.