From a646a5cce2ece3acc07ccead1e5f971cacc0db81 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 19 Sep 2019 09:18:42 +0200 Subject: [PATCH] Be tolerant of cropped TS_SHARECONTROLHEADER Old versions of Windows (e.g. XP) sends a cropped packet in some cases. It still contains all the important parts, so let's be tolerant of this misbehaviour. --- rdp.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/rdp.c b/rdp.c index 8ac0d28..a43a600 100644 --- a/rdp.c +++ b/rdp.c @@ -124,12 +124,22 @@ rdp_ts_in_share_control_header(STREAM s, uint8 * type, uint16 * length) } in_uint16_le(s, pdu_type); /* pduType */ - in_uint16(s, pdu_source); /* pduSource */ - *type = pdu_type & 0xf; + /* XP omits pduSource for PDUTYPE_DEACTIVATEALLPDU for some reason */ + if (*length == 4) { + logger(Protocol, Debug, + "rdp_ts_in_share_control_header(), missing pduSource field for 0x%x PDU", + *type); + } else { + in_uint16(s, pdu_source); /* pduSource */ + } + /* Give just the size of the data */ - *length -= 6; + if (*length >= 6) + *length -= 6; + else + *length = 0; return True; }