forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

decode_dv.rs40 lines, 1.4 KiBHistoryRawDownload
1#![no_main]
2
3// Untrusted entry: arbitrary bytes as a DV frame (video + audio extraction), as a frame whose
4// DIF header is forced valid for a profile chosen by the first byte (so the entropy decoder is
5// reached), and as a raw .dv stream through the demuxer. Errors are expected; only panics,
6// hangs and OOM count.
7
8use ec_core::registry::Demuxer;
9use ec_dv::{DvDemuxer, DvVideoDecoder, PROFILES, extract_audio, is_dv};
10use libfuzzer_sys::fuzz_target;
11
12fuzz_target!(|data: &[u8]| {
13 let Some((&sel, rest)) = data.split_first() else { return };
14 let mut dec = DvVideoDecoder::new();
15 let mut frame;
16 let buf: &[u8] = if usize::from(sel) < PROFILES.len() * 4 {
17 let p = &PROFILES[usize::from(sel) % PROFILES.len()];
18 frame = vec![0u8; p.frame_size];
19 let n = rest.len().min(frame.len());
20 frame[..n].copy_from_slice(&rest[..n]);
21 frame[3] = (frame[3] & 0x7f) | (p.dsf << 7);
22 let v = 80 * 5 + 48 + 3;
23 frame[v] = (frame[v] & 0x20) | p.video_stype;
24 &frame
25 } else {
26 data
27 };
28 if let Ok(pic) = dec.decode(buf) {
29 std::hint::black_box(pic);
30 }
31 std::hint::black_box(extract_audio(buf));
32 let _ = is_dv(data);
33 if let Ok(mut d) = DvDemuxer::new(std::io::Cursor::new(data.to_vec())) {
34 for _ in 0..4 {
35 if d.next_packet().is_err() {
36 break;
37 }
38 }
39 }
40});