You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
scuffle-expgolomb: read_exp_golomb underflows with 64+ leading zeros #654
BitReaderExpGolombExt::read_exp_golomb in scuffle-expgolomb 0.1.5 does not bound leading_zeros. With 64 or more leading zeros, result <<= 1 shifts the implicit leading 1 out of the u64, and Ok(result - 1) at src/lib.rs:88 then underflows. Debug builds panic with "attempt to subtract with overflow". Release builds return Ok(u64::MAX) (or another wrapped value), and callers range-check that as if it were real.
use scuffle_bytes_util::BitReader;use scuffle_expgolomb::BitReaderExpGolombExt;// 64 zero bits, the marker 1, then 64 zero suffix bits.letmut data = vec![0u8;8];
data.push(0x80);
data.extend([0u8;8]);letmut r = BitReader::new(std::io::Cursor::new(data));// debug: panics at lib.rs:88; release: Ok(18446744073709551615)let _ = r.read_exp_golomb();
The largest value a u64 ue(v) can hold needs 63 leading zeros, so returning io::ErrorKind::InvalidData once leading_zeros reaches 64 would fix both builds. H.264 and H.265 cap ue(v) at 2^32 - 2 (31 leading zeros), if you want the tighter bound. read_signed_exp_golomb inherits the fix.
Found by fuzzing scuffle-h265's SPS parser in moq-dev/moq.
Activity