forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

parse_params_slice.rs43 lines, 1.5 KiBHistoryRawDownload
1#![no_main]
2
3// Untrusted entry: a raw Annex B byte stream, parsed NAL by NAL with the
4// ec-h265-syntax parsers. Every VPS, SPS and PPS is parsed, every slice segment
5// header is parsed against the most recent SPS and PPS that parsed. Errors are
6// expected for malformed input; only panics, hangs and OOM count.
7
8use ec_h265_syntax::slice::SliceHeader;
9use ec_h265_syntax::{NalUnitType, Pps, Sps, Vps, split_annex_b};
10use libfuzzer_sys::fuzz_target;
11
12fuzz_target!(|data: &[u8]| {
13 let mut sps: Option<Sps> = None;
14 let mut pps: Option<Pps> = None;
15 for nal in split_annex_b(data) {
16 let rbsp = nal.rbsp();
17 match nal.header.nal_type {
18 NalUnitType::Vps => {
19 if let Ok(vps) = Vps::parse(&rbsp) {
20 std::hint::black_box(vps);
21 }
22 }
23 NalUnitType::Sps => {
24 if let Ok(parsed) = Sps::parse(&rbsp) {
25 sps = Some(parsed);
26 }
27 }
28 NalUnitType::Pps => {
29 if let Ok(parsed) = Pps::parse(&rbsp) {
30 pps = Some(parsed);
31 }
32 }
33 t if t.is_vcl() => {
34 if let (Some(s), Some(p)) = (&sps, &pps) {
35 if let Ok((header, positions)) = SliceHeader::parse(&rbsp, s, p, t) {
36 std::hint::black_box((header, positions.slice_data_byte_offset(nal.payload)));
37 }
38 }
39 }
40 _ => {}
41 }
42 }
43});