forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

fuzz_regressions.rs86 lines, 3.4 KiBHistoryRawDownload
1//! Regression inputs found by the `parse_params_slice` fuzz target (`crates/ec-h265/fuzz`).
2//!
3//! The input is parsed the way the target parses it: every VPS, SPS and PPS, and each
4//! slice header against the latest SPS and PPS. Each must come back without a panic
5//! or an allocation the input did not justify.
6
7use ec_h265_syntax::slice::SliceHeader;
8use ec_h265_syntax::{NalUnitType, Pps, Sps, Vps, split_annex_b};
9
10fn parse_params_slice(data: &[u8]) {
11 let mut sps: Option<Sps> = None;
12 let mut pps: Option<Pps> = None;
13 for nal in split_annex_b(data) {
14 let rbsp = nal.rbsp();
15 match nal.header.nal_type {
16 NalUnitType::Vps => {
17 let _ = Vps::parse(&rbsp);
18 }
19 NalUnitType::Sps => {
20 if let Ok(parsed) = Sps::parse(&rbsp) {
21 sps = Some(parsed);
22 }
23 }
24 NalUnitType::Pps => {
25 if let Ok(parsed) = Pps::parse(&rbsp) {
26 pps = Some(parsed);
27 }
28 }
29 t if t.is_vcl() => {
30 if let (Some(s), Some(p)) = (&sps, &pps) {
31 let _ = SliceHeader::parse(&rbsp, s, p, t);
32 }
33 }
34 _ => {}
35 }
36 }
37}
38
39/// A slice header whose `num_ref_idx_l0_active_minus1` comes from the PPS default
40/// and is out of range: `pred_weight_table` sized a Vec from it (a 2.6 GB malloc).
41#[test]
42fn pps_default_num_ref_idx_out_of_range_does_not_allocate() {
43 parse_params_slice(include_bytes!("data/fuzz/parse_params_slice-pred-weight-oom.bin"));
44}
45
46/// Long-term reference pictures whose `delta_poc_msb_cycle_lt` deltas accumulate past
47/// `u32::MAX` (7-52): the running sum overflowed in `SliceHeader::parse`.
48#[test]
49fn delta_poc_msb_cycle_accumulation_does_not_overflow() {
50 parse_params_slice(include_bytes!("data/fuzz/parse_params_slice-delta-msb-overflow.bin"));
51}
52
53/// A short-term reference picture set whose `delta_poc_s0_minus1` is far past its
54/// 2^15 - 1 range: the running POC sum overflowed (`attempt to subtract with overflow`).
55#[test]
56fn short_term_rps_delta_poc_out_of_range_does_not_overflow() {
57 parse_params_slice(include_bytes!("data/fuzz/parse_params_slice-rps-delta-overflow.bin"));
58}
59
60/// An inter-predicted short-term RPS whose `abs_delta_rps_minus1` is out of range:
61/// `delta_rps` and the POC sums built from it overflowed `i32`.
62#[test]
63fn inter_rps_abs_delta_out_of_range_does_not_overflow() {
64 parse_params_slice(include_bytes!("data/fuzz/parse_params_slice-inter-rps-overflow.bin"));
65}
66
67/// A pred_weight_table whose chroma log2 weight denominator is the luma one plus a
68/// near-`i32::MAX` delta: the sum overflowed.
69#[test]
70fn pred_weight_chroma_denom_sum_does_not_overflow() {
71 parse_params_slice(include_bytes!("data/fuzz/parse_params_slice-weight-denom-overflow.bin"));
72}
73
74/// A slice header whose long-term picture counts sum past `u32::MAX`: the loop bound
75/// `num_long_term_sps + num_long_term_pics` overflowed.
76#[test]
77fn long_term_picture_count_sum_does_not_overflow() {
78 parse_params_slice(include_bytes!("data/fuzz/parse_params_slice-long-term-count.bin"));
79}
80
81/// A slice header whose entry point offset is read as the all-ones 32-bit value: the
82/// `+ 1` that makes it a length overflowed.
83#[test]
84fn entry_point_offset_all_ones_does_not_overflow() {
85 parse_params_slice(include_bytes!("data/fuzz/parse_params_slice-entry-point-overflow.bin"));
86}