[BUG] read_exp_golomb_unsigned panics/aborts on 64 or more leading zero bits (malformed SPS)
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 76/100
Research direction
Start in src/rust/lib_ccxr/src/common/bitstream.rs with read_exp_golomb_unsigned, then trace the C forwarding function in cc_bitstream.c and its use from seq_parameter_set_rbsp() in avc_functions.c. Add a unit test decoding 64 zero bits and check that malformed input returns a BitstreamError rather than panicking or terminating the process; verify the SPS path can skip the NAL.
Written by the indexing model from the issue text.
Description
Summary
BitStreamRust::read_exp_golomb_unsigned (src/rust/lib_ccxr/src/common/bitstream.rs) does not limit the number of leading zero bits, so a short malformed H.264 SPS can panic (debug builds), return a wrong value (release builds) or terminate the process.
pub fn read_exp_golomb_unsigned(&mut self) -> Result<u64, BitstreamError> {
let mut zeros = 0;
while self.read_bits(1)? == 0 && self.bits_left >= 0 {
zeros += 1;
}
let remaining_bits = self.read_bits(zeros)?;
let res = ((1u64 << zeros) - 1) + remaining_bits;
Ok(res)
}
- Exactly 64 leading zeros:
1u64 << 64overflows. Debug build:panicked at ... attempt to shift left with overflow. Release build: the shift count is masked, so the result is silently wrong (1u64 << 0). - More than 64 leading zeros:
read_bitsrejectsbnum > 64withfatal!, which exits the process.
Reachability
cc_bitstream.c forwards read_exp_golomb_unsigned() to this function, and seq_parameter_set_rbsp() in avc_functions.c calls it for seq_parameter_set_id. An SPS made of the 3-byte header followed by 8-9 zero bytes reaches it from do_NAL().
Reproduction
A lib_ccxr unit test that decodes 64 zero bits panics in a debug build. 9 zero bytes in an SPS makes the process exit through fatal!.
Expected
A BitstreamError that lets the caller skip the NAL.
Suggested fix
Return Err when zeros >= 64 (and have read_bits return Err instead of calling fatal! for bnum > 64). A related spot is slice_header(), which does 1 << log2_max_frame_num in C; H.264 only allows 4..16 there.
- Dominant language
- C
- Stars
- 919
- Forks
- 604
- Avg merge
- 9d 5h
- Merged PRs (30d)
- 26
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CCExtractor/ccextractor
-
GXF: heap buffer overflow in parse_ad_cdp() — unbounded cc_count in CDP cc data sectionPossibly taken @pranayr710 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
CCExtractor/ccextractor#2498 ·
Maintainers usually reply within 1 day
-
[BUG] + file-sequence expansion picks the digit in the extension (clip001.mp4+ only processes clip001.mp4)Possibly taken @imfarhan0105-bits claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
CCExtractor/ccextractor#2478 · 2 comments ·
Maintainers usually reply within 1 day
-
[BUG] encoders: WebVTT encoder generates invalid ## delimiter and malformed @import violating W3C specificationPossibly taken @yasar710 claimed this 7 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
CCExtractor/ccextractor#2465 · 2 comments ·
Maintainers usually reply within 1 day
-
GXF: heap buffer overflow in parse_mpeg_packet() — oversized mpeg_pic_size overflows the demuxer bufferPossibly taken @pranayr710 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
CCExtractor/ccextractor#2500 ·
Maintainers usually reply within 1 day
-
[BUG] DVB: map-table cases in dvbsub_parse_pixel_data_block read past the object field dataPossibly taken @pranayr710 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 30/100
CCExtractor/ccextractor#2482 ·
Maintainers usually reply within 1 day
All issues in CCExtractor/ccextractor
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area: services kind: bug preview-effort: small priority: low
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Static Analysis failurePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100