[domistream] Tests: fuzz targets assert invariants
Every target now checks properties instead of only calling the parser: parse -> encode -> parse stability (RTSP request, ENet, input), caps and TooLarge past them, chunking invariance of the framer, XML vs status parser agreement, seal/open round trips, no forged GCM tags. New targets for the parsers and state machines that had none: server_cert_der, enet_client, media_decrypt, video_depacketizer, audio_depacketizer, fec_reconstruct, pairing_session, rtsp_client (25 targets).
This commit is contained in:
@@ -1,11 +1,24 @@
|
||||
//! Fuzzes `/applist` answers: never panics, whatever the bytes.
|
||||
//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic.
|
||||
//! Fuzzes `/applist` answers.
|
||||
//! Asserts invariants, not only "no panic": at most MAX_APPS apps, titles within the cap, ids unique.
|
||||
//! How to run: see the comment at the top of `fuzz/Cargo.toml`.
|
||||
|
||||
#![no_main]
|
||||
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
|
||||
use domistream::http::applist::{MAX_APP_TITLE_BYTES, MAX_APPLIST_BYTES, MAX_APPS};
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
let _ = domistream::http::parse_app_list(data);
|
||||
let r = domistream::http::parse_app_list(data);
|
||||
if data.len() > MAX_APPLIST_BYTES {
|
||||
assert!(matches!(r, Err(domistream::Error::TooLarge { .. })));
|
||||
}
|
||||
if let Ok(apps) = r {
|
||||
assert!(apps.len() <= MAX_APPS);
|
||||
let mut ids: Vec<u32> = apps.iter().map(|a| a.id).collect();
|
||||
ids.sort_unstable();
|
||||
ids.dedup();
|
||||
assert_eq!(ids.len(), apps.len(), "duplicate ids accepted");
|
||||
assert!(apps.iter().all(|a| a.title.len() <= MAX_APP_TITLE_BYTES));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user