mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-21 02:33:23 +00:00
feeafe40c9
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.
27 lines
701 B
Rust
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()),
|
|
}
|
|
}
|
|
});
|