Skip to content

Commit 7ac880d

Browse files
committed
Some TPKT packet could have less than 7 bytes as expected by specification
1 parent 600d6e5 commit 7ac880d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/core/tpkt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<S: Read + Write> Client<S> {
138138

139139
// Minimal size must be 7
140140
// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/18a27ef9-6f9a-4501-b000-94b1fe3c2c10
141-
if size.inner() < 7 {
141+
if size.inner() < 4 {
142142
Err(Error::RdpError(RdpError::new(RdpErrorKind::InvalidSize, "Invalid minimal size for TPKT")))
143143
}
144144
else {
@@ -155,14 +155,14 @@ impl<S: Read + Write> Client<S> {
155155
hi_length.read(&mut Cursor::new(self.transport.read(1)?))?;
156156
let length: u16 = ((short_length & !0x80) as u16) << 8;
157157
let length = length | hi_length as u16;
158-
if length < 7 {
158+
if length < 3 {
159159
Err(Error::RdpError(RdpError::new(RdpErrorKind::InvalidSize, "Invalid minimal size for TPKT")))
160160
} else {
161161
Ok(Payload::FastPath(sec_flag, Cursor::new(self.transport.read(length as usize - 3)?)))
162162
}
163163
}
164164
else {
165-
if short_length < 7 {
165+
if short_length < 2 {
166166
Err(Error::RdpError(RdpError::new(RdpErrorKind::InvalidSize, "Invalid minimal size for TPKT")))
167167
} else {
168168
Ok(Payload::FastPath(sec_flag, Cursor::new(self.transport.read(short_length as usize - 2)?)))

0 commit comments

Comments
 (0)