Skip to content

Commit

Permalink
Allow compilation with --cfg fuzzing but not --features=arbitrary
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius authored and djc committed May 27, 2023
1 parent 0c6b743 commit ede4344
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions quinn-proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ pub mod fuzzing {
pub use crate::frame::ResetStream;
pub use crate::packet::PartialDecode;
pub use crate::transport_parameters::TransportParameters;
use crate::MAX_CID_SIZE;
use arbitrary::{Arbitrary, Result, Unstructured};
pub use bytes::{BufMut, BytesMut};

#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Result, Unstructured};

#[cfg(feature = "arbitrary")]
impl<'arbitrary> Arbitrary<'arbitrary> for TransportParameters {
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self> {
Ok(Self {
Expand All @@ -111,9 +113,10 @@ pub mod fuzzing {
pub grease_quic_bit: bool,
}

#[cfg(feature = "arbitrary")]
impl<'arbitrary> Arbitrary<'arbitrary> for PacketParams {
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self> {
let local_cid_len: usize = u.int_in_range(0..=MAX_CID_SIZE)?;
let local_cid_len: usize = u.int_in_range(0..=crate::MAX_CID_SIZE)?;
let bytes: Vec<u8> = Vec::arbitrary(u)?;
let mut buf = BytesMut::new();
buf.put_slice(&bytes[..]);
Expand Down

0 comments on commit ede4344

Please sign in to comment.