Files
DomiStream/fuzz/fuzz_targets/rtsp_client.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

39 lines
1.4 KiB
Rust

//! Fuzzes the RTSP client state machine with hostile answers.
//! Asserts invariants, not only "no panic": the requests it emits always parse, and it never reports Ready before a full exchange.
//! How to run: see the comment at the top of `fuzz/Cargo.toml`.
#![no_main]
use libfuzzer_sys::fuzz_target;
use domistream::http::launch::AudioLayout;
use domistream::rtsp::client::VideoCodec;
use domistream::rtsp::{EncryptionFlags, RtspClient, RtspProgress, StreamConfig, parse_request};
fuzz_target!(|data: &[u8]| {
let config = StreamConfig {
width: 1920,
height: 1080,
fps: 60,
bitrate_kbps: 20_000,
packet_size: 1024,
codec: VideoCodec::Hevc,
hdr: false,
audio: AudioLayout::Stereo,
audio_packet_duration_ms: 5,
min_fec_packets: 2,
reference_frame_invalidation: true,
encryption: EncryptionFlags(7),
};
let Ok(mut c) = RtspClient::new("rtsp://192.0.2.10:48010", config) else { return };
// Answers separated by NUL bytes.
for (answers, answer) in data.split(|b| *b == 0).take(8).enumerate() {
if let Some(req) = c.poll_request() {
parse_request(&req).expect("the client's requests parse");
}
if let Ok(RtspProgress::Ready(_)) = c.handle_response(answer) {
assert!(answers >= 6, "Ready after {} answers", answers + 1);
}
}
});