[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,12 +1,24 @@
|
||||
//! Fuzzes video packets and the frame header: never panics, whatever the bytes.
|
||||
//! Phase A: the parser returns `Unimplemented`; QA adds the properties (round trips, caps) with the logic.
|
||||
//! Fuzzes video packets and the frame header.
|
||||
//! Asserts invariants, not only "no panic": FEC fields are consistent on success, the payload is the rest of the packet, the frame header keeps its raw bytes.
|
||||
//! How to run: see the comment at the top of `fuzz/Cargo.toml`.
|
||||
|
||||
#![no_main]
|
||||
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
|
||||
use domistream::video::packet::{FRAME_HEADER_LEN, MAX_VIDEO_PACKET_BYTES, PAYLOAD_OFFSET, parse_frame_header};
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
let _ = domistream::video::parse_video_packet(data);
|
||||
let _ = domistream::video::packet::parse_frame_header(data);
|
||||
if let Ok(p) = domistream::video::parse_video_packet(data) {
|
||||
assert!(data.len() >= PAYLOAD_OFFSET && data.len() <= MAX_VIDEO_PACKET_BYTES);
|
||||
assert_eq!(p.payload.len() + PAYLOAD_OFFSET, data.len());
|
||||
let f = p.nv.fec;
|
||||
assert!(f.data_shards > 0 && f.block_index <= f.last_block_index && f.last_block_index < 4);
|
||||
let m = domistream::fec::parity_count(usize::from(f.data_shards), f.fec_percentage).expect("a consistent block");
|
||||
assert!(usize::from(f.shard_index) < usize::from(f.data_shards) + m);
|
||||
assert!(usize::from(f.data_shards) + m <= domistream::fec::MAX_SHARDS);
|
||||
}
|
||||
if let Ok(h) = parse_frame_header(data) {
|
||||
assert_eq!(&h.raw[..], &data[..FRAME_HEADER_LEN]);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user