Skip to content

bug: obs-avc.c get_ue_golomb can evaluate 1 << 32 (undefined behavior) on a truncated SPS #11

Closed

Description

@zackees

libobs/obs-avc.c:167-173, get_ue_golomb:

while (i < 32 && !bitstream_reader_read_bits(gb, 1))
	i++;
return bitstream_reader_read_bits(gb, i) + (1 << i) - 1;

The bitstream reader returns 0 for every read past the end of the buffer, so a truncated or malformed SPS lets the loop count 32 zero bits. 1 << 32 on a 32-bit int is then undefined behavior in C. Found during the Rust port research. Issue #8 (Phase 5) says to fix it in C separately, not silently in the port. It also has to be excluded from Tier 3 fuzz parity until it's fixed.

Suggested fix: cap the leading-zero count at 31 (or treat 32 as an error) and compute with an unsigned type.

Refs #4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions