forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

decode_dnxhd.rs32 lines, 1.1 KiBHistoryRawDownload
1#![no_main]
2
3// Untrusted entry: arbitrary bytes as one DNxHD/DNxHR frame packet. Errors are
4// expected for malformed input; only panics, hangs and OOM count.
5
6use ec_core::registry::{CodecId, CodecParameters};
7use ec_dnxhd::DnxhdDecoder;
8use libfuzzer_sys::fuzz_target;
9
10/// Harness cap: pictures larger than this are skipped (the decoder itself
11/// bounds allocation at 8192x4608; the cap keeps fuzz runs fast).
12const MAX_PIXELS: u64 = 2_000_000;
13
14fuzz_target!(|data: &[u8]| {
15 if data.len() >= 0x1c {
16 let h = u64::from(u16::from_be_bytes([data[0x18], data[0x19]]));
17 let w = u64::from(u16::from_be_bytes([data[0x1a], data[0x1b]]));
18 // Interlaced frames double the stated height.
19 if w * h * 2 > MAX_PIXELS {
20 return;
21 }
22 }
23 let Ok(mut dec) = DnxhdDecoder::new(CodecParameters::new(CodecId::Dnxhd)) else {
24 return;
25 };
26 dec.set_threads(1 + data.len() % 3);
27 if data.first().is_some_and(|b| b & 1 == 1) {
28 let _ = std::hint::black_box(dec.decode_native(data));
29 } else {
30 let _ = std::hint::black_box(dec.decode_bytes(data));
31 }
32});