Files
noq/fuzz/fuzz_targets/packet.rs
LAN Xingcan ee1c0fd143 proto: introduce ConnectionIdParser
Currently `PlainHeader::decode` and `PartialDecoder::new` expect a
`local_cid_len`, which means they cannot support variable length
Connection ID format and make it less useful in various use cases,
such as implementing a [QUIC-LB] confirming load balancer.

[QUIC-LB]: https://www.ietf.org/archive/id/draft-ietf-quic-load-balancers-19.html
2024-05-22 23:58:44 +02:00

26 lines
684 B
Rust

#![no_main]
extern crate proto;
use libfuzzer_sys::fuzz_target;
use proto::{
fuzzing::{PacketParams, PartialDecode},
FixedLengthConnectionIdParser, DEFAULT_SUPPORTED_VERSIONS,
};
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()),
}
}
});