From 7ac880d7efb7f05efef3c84476f7c24f4053e0ea Mon Sep 17 00:00:00 2001 From: citronneur Date: Tue, 9 Mar 2021 10:53:47 +0100 Subject: [PATCH] Some TPKT packet could have less than 7 bytes as expected by specification --- src/core/tpkt.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/tpkt.rs b/src/core/tpkt.rs index 8651c47..cb06e37 100644 --- a/src/core/tpkt.rs +++ b/src/core/tpkt.rs @@ -138,7 +138,7 @@ impl Client { // Minimal size must be 7 // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/18a27ef9-6f9a-4501-b000-94b1fe3c2c10 - if size.inner() < 7 { + if size.inner() < 4 { Err(Error::RdpError(RdpError::new(RdpErrorKind::InvalidSize, "Invalid minimal size for TPKT"))) } else { @@ -155,14 +155,14 @@ impl Client { hi_length.read(&mut Cursor::new(self.transport.read(1)?))?; let length: u16 = ((short_length & !0x80) as u16) << 8; let length = length | hi_length as u16; - if length < 7 { + if length < 3 { Err(Error::RdpError(RdpError::new(RdpErrorKind::InvalidSize, "Invalid minimal size for TPKT"))) } else { Ok(Payload::FastPath(sec_flag, Cursor::new(self.transport.read(length as usize - 3)?))) } } else { - if short_length < 7 { + if short_length < 2 { Err(Error::RdpError(RdpError::new(RdpErrorKind::InvalidSize, "Invalid minimal size for TPKT"))) } else { Ok(Payload::FastPath(sec_flag, Cursor::new(self.transport.read(short_length as usize - 2)?)))