fix exp-golomb bit position in avc_nalu_read_uev - #3483
Open
ubeddulla wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Exp-Golomb decoding for AVC SPS parsing and adds regression coverage for decoded dimensions.
Changes:
- Corrects bit positioning in
avc_nalu_read_uev. - Adds SPS regression coverage for width and height decoding.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
test/brpc_rtmp_unittest.cpp |
Adds regression coverage for AVC SPS dimensions. |
src/brpc/details/rtmp_utils.cpp |
Fixes Exp-Golomb bit accumulation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
avc_nalu_read_uev adds every Exp-Golomb value bit at the constant shift leadingZeroBits-1 instead of the descending leadingZeroBits-1-i, so any ue(v) code with two or more leading zero bits decodes to the wrong number and a crafted SPS overflows the int32 accumulator past INT32_MAX (UBSan reports the signed overflow). The decoder runs on the SPS inside an untrusted RTMP AVC sequence header, reached through AVCDecoderConfigurationRecord::Create. Shift each bit into its correct position so the result matches the H.264 read_bits(leadingZeroBits) semantics and stays in range.