From 698fd812436100b0fd1c4c03d13d9b52c1433ea0 Mon Sep 17 00:00:00 2001 From: Moritz Bitsch Date: Thu, 23 Nov 2023 14:16:32 +0100 Subject: [PATCH] Reset too big packet lengths back to None --- src/de/packet_reader.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/de/packet_reader.rs b/src/de/packet_reader.rs index 1b49594..d96ecc2 100644 --- a/src/de/packet_reader.rs +++ b/src/de/packet_reader.rs @@ -55,6 +55,12 @@ impl<'a> PacketReader<'a> { } } + if let Some(packet_length) = self.packet_length { + if packet_length > self.buffer.len() { + self.packet_length = None; + } + } + // We should have found the packet length by now. if self.read_bytes >= 5 && self.packet_length.is_none() { return Err(Error::MalformedPacket);