diff --git a/neqo-transport/Cargo.toml b/neqo-transport/Cargo.toml index 125da11508..c826b0d0cd 100644 --- a/neqo-transport/Cargo.toml +++ b/neqo-transport/Cargo.toml @@ -28,6 +28,7 @@ test-fixture = { path = "../test-fixture" } [features] bench = [] disable-encryption = ["neqo-crypto/disable-encryption"] +fuzzing = [] [lib] # See https://github.com/bheisler/criterion.rs/blob/master/book/src/faq.md#cargo-bench-gives-unrecognized-option-errors-for-valid-command-line-options diff --git a/neqo-transport/src/packet/mod.rs b/neqo-transport/src/packet/mod.rs index 5151def1f9..552e50a1f9 100644 --- a/neqo-transport/src/packet/mod.rs +++ b/neqo-transport/src/packet/mod.rs @@ -256,10 +256,6 @@ impl PacketBuilder { /// Maybe pad with "PADDING" frames. /// Only does so if padding was needed and this is a short packet. /// Returns true if padding was added. - /// - /// # Panics - /// - /// Cannot happen. pub fn pad(&mut self) -> bool { if self.padding && !self.is_long() { self.encoder @@ -294,7 +290,6 @@ impl PacketBuilder { /// The length is filled in after calling `build`. /// Does nothing if there isn't 4 bytes available other than render this builder /// unusable; if `remaining()` returns 0 at any point, call `abort()`. - #[allow(clippy::missing_panics_doc)] pub fn pn(&mut self, pn: PacketNumber, pn_len: usize) { if self.remaining() < 4 { self.limit = 0; @@ -359,8 +354,6 @@ impl PacketBuilder { } /// Build the packet and return the encoder. - #[allow(clippy::missing_errors_doc)] - #[allow(clippy::missing_panics_doc)] pub fn build(mut self, crypto: &mut CryptoDxState) -> Res { if self.len() > self.limit { qwarn!("Packet contents are more than the limit"); @@ -420,7 +413,6 @@ impl PacketBuilder { /// As Retry is odd (it has to be constructed with leading bytes), /// this returns a [`Vec`] rather than building on an encoder. #[allow(clippy::similar_names)] // scid and dcid are fine here. - #[allow(clippy::missing_errors_doc)] pub fn retry( version: Version, dcid: &[u8], @@ -453,7 +445,6 @@ impl PacketBuilder { /// Make a Version Negotiation packet. #[allow(clippy::similar_names)] // scid and dcid are fine here. - #[must_use] pub fn version_negotiation( dcid: &[u8], scid: &[u8], @@ -566,8 +557,6 @@ impl<'a> PublicPacket<'a> { /// Decode the common parts of a packet. This provides minimal parsing and validation. /// Returns a tuple of a `PublicPacket` and a slice with any remainder from the datagram. #[allow(clippy::similar_names)] // For dcid and scid, which are fine. - #[allow(clippy::missing_panics_doc)] - #[allow(clippy::missing_errors_doc)] pub fn decode(data: &'a [u8], dcid_decoder: &dyn ConnectionIdDecoder) -> Res<(Self, &'a [u8])> { let mut decoder = Decoder::new(data); let first = Self::opt(decoder.decode_byte())?; @@ -658,8 +647,6 @@ impl<'a> PublicPacket<'a> { } /// Validate the given packet as though it were a retry. - #[must_use] - #[allow(clippy::missing_panics_doc)] pub fn is_valid_retry(&self, odcid: &ConnectionId) -> bool { if self.packet_type != PacketType::Retry { return false; @@ -680,7 +667,6 @@ impl<'a> PublicPacket<'a> { .unwrap_or(false) } - #[must_use] pub fn is_valid_initial(&self) -> bool { // Packet has to be an initial, with a DCID of 8 bytes, or a token. // Note: the Server class validates the token and checks the length. @@ -688,49 +674,36 @@ impl<'a> PublicPacket<'a> { && (self.dcid().len() >= 8 || !self.token.is_empty()) } - #[must_use] pub fn packet_type(&self) -> PacketType { self.packet_type } - #[must_use] pub fn dcid(&self) -> ConnectionIdRef<'a> { self.dcid } - #[must_use] - #[allow(clippy::missing_panics_doc)] pub fn scid(&self) -> ConnectionIdRef<'a> { self.scid .expect("should only be called for long header packets") } - #[must_use] pub fn token(&self) -> &'a [u8] { self.token } - #[must_use] pub fn version(&self) -> Option { self.version.and_then(|v| Version::try_from(v).ok()) } - #[must_use] pub fn wire_version(&self) -> WireVersion { debug_assert!(self.version.is_some()); self.version.unwrap_or(0) } - #[must_use] pub fn len(&self) -> usize { self.data.len() } - #[must_use] - pub fn is_empty(&self) -> bool { - self.data.is_empty() - } - fn decode_pn(expected: PacketNumber, pn: u64, w: usize) -> PacketNumber { let window = 1_u64 << (w * 8); let candidate = (expected & !(window - 1)) | pn; @@ -805,8 +778,6 @@ impl<'a> PublicPacket<'a> { )) } - #[allow(clippy::missing_errors_doc)] - #[allow(clippy::missing_panics_doc)] pub fn decrypt(&self, crypto: &mut CryptoStates, release_at: Instant) -> Res { let cspace: CryptoSpace = self.packet_type.into(); // When we don't have a version, the crypto code doesn't need a version @@ -844,8 +815,6 @@ impl<'a> PublicPacket<'a> { } } - #[allow(clippy::missing_panics_doc)] - #[allow(clippy::missing_errors_doc)] pub fn supported_versions(&self) -> Res> { assert_eq!(self.packet_type, PacketType::VersionNegotiation); let mut decoder = Decoder::new(&self.data[self.header_len..]); @@ -878,17 +847,14 @@ pub struct DecryptedPacket { } impl DecryptedPacket { - #[must_use] pub fn version(&self) -> Version { self.version } - #[must_use] pub fn packet_type(&self) -> PacketType { self.pt } - #[must_use] pub fn pn(&self) -> PacketNumber { self.pn }