forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

decode_mjpeg.rs30 lines, 950 bytesHistoryRawDownload
1#![no_main]
2
3use ec_core::frame::Interlace;
4use ec_image::Limits;
5use libfuzzer_sys::fuzz_target;
6
7const LIMITS: Limits = Limits {
8 max_pixels: 4096 * 4096,
9 max_alloc: 1 << 26,
10 max_total_alloc: 1 << 27,
11};
12
13// The first input byte steers the container height (0 = unknown, otherwise a multiple of the
14// field height) and the field order, so both the single-image and two-field paths are reached.
15fuzz_target!(|data: &[u8]| {
16 let Some((&steer, rest)) = data.split_first() else {
17 return;
18 };
19 let height = u32::from(steer & 0x0f) * 16;
20 let order = if steer & 0x10 != 0 {
21 Interlace::BottomFieldFirst
22 } else {
23 Interlace::TopFieldFirst
24 };
25 if let Ok(f) = ec_mjpeg::decode_frame(rest, height, order, LIMITS) {
26 // Every accepted frame must be well formed: try_new validated plane sizes.
27 assert!(f.color.full_range);
28 }
29 let _ = ec_image::jpeg::decode_yuv(rest, LIMITS);
30});