From f4d73054a954efabc5a4b0922f278b848577ee4b Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Sun, 29 Sep 2024 14:51:38 +0100 Subject: [PATCH] Use client earlyCapabilities to determine channel join count We always now indicate we support skipping channel joins. If the client indicates this too, expect no channel join requests from the client. If we do get some, process them anyway. --- common/ms-rdpbcgr.h | 1 + libxrdp/xrdp_mcs.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/common/ms-rdpbcgr.h b/common/ms-rdpbcgr.h index eb6ea8691..5e85a5a17 100644 --- a/common/ms-rdpbcgr.h +++ b/common/ms-rdpbcgr.h @@ -80,6 +80,7 @@ #define RNS_UD_CS_WANT_32BPP_SESSION 0x0002 #define RNS_UD_CS_SUPPORT_MONITOR_LAYOUT_PDU 0x0040 #define RNS_UD_CS_SUPPORT_DYNVC_GFX_PROTOCOL 0x0100 +#define RNS_UD_CS_SUPPORT_SKIP_CHANNELJOIN 0x0800 /* Client Core Data: connectionType (2.2.1.3.2) */ #define CONNECTION_TYPE_MODEM 0x01 diff --git a/libxrdp/xrdp_mcs.c b/libxrdp/xrdp_mcs.c index d596d2b7d..3a056da1f 100644 --- a/libxrdp/xrdp_mcs.c +++ b/libxrdp/xrdp_mcs.c @@ -1129,11 +1129,20 @@ handle_channel_join_requests(struct xrdp_mcs *self, struct stream *s, int *appid) { int rv = 0; - /* - * Expect a channel join request PDU for each of the static virtual - * channels, plus the user channel (self->chanid) and the I/O channel - * (MCS_GLOBAL_CHANNEL) */ - unsigned int expected_join_count = self->channel_list->count + 2; + unsigned int expected_join_count = 0; + if ((self->sec_layer->rdp_layer->client_info.mcs_early_capability_flags & + RNS_UD_CS_SUPPORT_SKIP_CHANNELJOIN) == 0) + { + /* + * The client has indicated it does not support skipping channel + * join request/confirm PDUs. + * + * Expect a channel join request PDU for each of the static + * virtual channels, plus the user channel (self->chanid) and + * the I/O channel (MCS_GLOBAL_CHANNEL) */ + expected_join_count = self->channel_list->count + 2; + } + unsigned int actual_join_count = 0; while (*appid == MCS_CJRQ)