Files
DomiStream/fuzz/fuzz_targets/pair_response.rs
T
mnovak 948f446a13 [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).
2026-11-25 12:51:08 +01:00

22 lines
708 B
Rust

//! Fuzzes pairing answers.
//! Asserts invariants, not only "no panic": decoded values are at most half the body (hex), oversize is TooLarge.
//! How to run: see the comment at the top of `fuzz/Cargo.toml`.
#![no_main]
use libfuzzer_sys::fuzz_target;
use domistream::pairing::MAX_PAIR_RESPONSE_BYTES;
fuzz_target!(|data: &[u8]| {
let r = domistream::pairing::parse_pair_response(data);
if data.len() > MAX_PAIR_RESPONSE_BYTES {
assert!(matches!(r, Err(domistream::Error::TooLarge { .. })));
}
if let Ok(p) = r {
for v in [&p.plain_cert, &p.challenge_response, &p.pairing_secret].into_iter().flatten() {
assert!(v.len() * 2 <= data.len());
}
}
});