Skip to content

fix exp-golomb bit position in avc_nalu_read_uev - #3483

Open
ubeddulla wants to merge 1 commit into
apache:masterfrom
ubeddulla:avc-uev-bit-shift
Open

fix exp-golomb bit position in avc_nalu_read_uev#3483
ubeddulla wants to merge 1 commit into
apache:masterfrom
ubeddulla:avc-uev-bit-shift

Conversation

@ubeddulla

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants