Files
noq/fuzz/fuzz_targets/packet.rs
Rüdiger Klaehn feeafe40c9 Disable fuzz code unless fuzzing config is set (#309)
With this we no longer get compile errors in vscode because the fuzzing
code uses fns that are themselves gated with cfg(fuzzing).

We have to tell rust about the feature in Cargo.toml to avoid warnings.
2026-01-13 09:20:49 +00:00

27 lines
701 B
Rust

#![no_main]
#![cfg(fuzzing)]
extern crate proto;
use libfuzzer_sys::fuzz_target;
use proto::{
DEFAULT_SUPPORTED_VERSIONS, FixedLengthConnectionIdParser,
fuzzing::{PacketParams, PartialDecode},
};
fuzz_target!(|data: PacketParams| {
let len = data.buf.len();
let supported_versions = DEFAULT_SUPPORTED_VERSIONS.to_vec();
if let Ok(decoded) = PartialDecode::new(
data.buf,
&FixedLengthConnectionIdParser::new(data.local_cid_len),
&supported_versions,
data.grease_quic_bit,
) {
match decoded.1 {
Some(x) => assert_eq!(len, decoded.0.len() + x.len()),
None => assert_eq!(len, decoded.0.len()),
}
}
});