forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

fuzz_regressions.rs24 lines, 1.1 KiBHistoryRawDownload
1//! Regression inputs found by the `h264_build_parameters` fuzz target
2//! (`crates/ec-hw/fuzz`).
3//!
4//! Each input must be refused without a panic.
5
6use ec_h264_syntax::{AnnexBIter, NalHeader, NalUnitType, Pps, unescape_rbsp};
7
8/// A PPS whose scaling list carries a `delta_scale` far outside -128..=127. The sum
9/// `last_scale + delta_scale + 256` in `parse_scaling_list` overflowed, which panics
10/// in a debug or fuzzing build. Out-of-range values are corrupt (7.4.2.1.1).
11#[test]
12fn pps_scaling_delta_out_of_range_is_corrupt_not_a_panic() {
13 let data = include_bytes!("data/fuzz/pps-scaling-delta-overflow.bin");
14 let nal = AnnexBIter::new(data)
15 .next()
16 .expect("the fixture holds one NAL unit");
17 let (&first, payload) = nal.split_first().expect("a NAL header byte");
18 let header = NalHeader::parse(first).expect("a valid NAL header");
19 assert_eq!(header.unit_type, NalUnitType::Pps);
20 let mut rbsp = Vec::new();
21 unescape_rbsp(payload, &mut rbsp);
22 let err = Pps::parse(&rbsp, |_| None).expect_err("an out-of-range delta_scale is corrupt");
23 assert!(err.to_string().contains("delta_scale"), "wrong refusal: {err}");
24}