[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,18 @@
|
||||
//! Fuzzes INPUT_DATA messages: never panics, whatever the bytes.
|
||||
//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic.
|
||||
//! Fuzzes INPUT_DATA messages.
|
||||
//! Asserts invariants, not only "no panic": parse -> encode -> parse is stable; an accepted message's length field matches.
|
||||
//! How to run: see the comment at the top of `fuzz/Cargo.toml`.
|
||||
|
||||
#![no_main]
|
||||
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
|
||||
use domistream::input::{MAX_INPUT_MESSAGE_BYTES, encode_input, parse_input};
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
let _ = domistream::input::parse_input(data);
|
||||
if let Ok(e) = parse_input(data) {
|
||||
assert!(data.len() <= MAX_INPUT_MESSAGE_BYTES);
|
||||
assert_eq!(usize::from(u16::from_le_bytes([data[2], data[3]])) + 4, data.len());
|
||||
let bytes = encode_input(&e).expect("a parsed event encodes");
|
||||
assert_eq!(parse_input(&bytes), Ok(e));
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user