forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

decode_raw.rs33 lines, 1.3 KiBHistoryRawDownload
1#![no_main]
2
3// Input layout:
4// byte 0 selects one of the four AudioSpecificConfigs below (mod 4)
5// then raw_data_block access units, each prefixed by a u16 big-endian length
6// (a length past the end of the input is clamped to what remains)
7
8use ec_aac::AacDecoder;
9use libfuzzer_sys::fuzz_target;
10
11// Valid, hand-packed AudioSpecificConfigs (ISO/IEC 14496-3 1.6.2.1).
12const CONFIGS: [&[u8]; 4] = [
13 &[0x11, 0x88], // AAC-LC, 48 kHz, mono
14 &[0x11, 0x90], // AAC-LC, 48 kHz, stereo
15 &[0x2B, 0x23, 0x10], // HE-AAC (explicit SBR): core 24 kHz, stereo, SBR at 48 kHz
16 &[0x11, 0xB0], // AAC-LC, 48 kHz, 5.1
17];
18
19fuzz_target!(|data: &[u8]| {
20 let Some((&sel, mut rest)) = data.split_first() else {
21 return;
22 };
23 let asc = CONFIGS[(sel as usize) % CONFIGS.len()];
24 // The configs are constants above, so a parse failure is a harness bug, not an input finding.
25 let mut dec = AacDecoder::with_config_bytes(asc).expect("built-in AudioSpecificConfig must parse");
26 while rest.len() >= 2 {
27 let len = u16::from_be_bytes([rest[0], rest[1]]) as usize;
28 rest = &rest[2..];
29 let (au, tail) = rest.split_at(len.min(rest.len()));
30 let _ = dec.decode(au, None);
31 rest = tail;
32 }
33});