From 4c38ab777be241a6613e83ec405d4ff023bc87b1 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Tue, 6 Aug 2024 09:36:37 +0100 Subject: [PATCH] Send module version to xrdp This change sends the CLIENT_INFO_CURRENT_VERSION that the module was compiled with to xrdp as part of the capabilities. This lets xrdp check the version before connecting to this module. xrdp can then abort the connect if the version doesn't match. --- module/rdpClientCon.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/module/rdpClientCon.c b/module/rdpClientCon.c index 8b3ac2f..7b44e7f 100644 --- a/module/rdpClientCon.c +++ b/module/rdpClientCon.c @@ -635,33 +635,34 @@ rdpClientConSendCaps(rdpPtr dev, rdpClientCon *clientCon) int len; int rv; int cap_count; - int cap_bytes; make_stream(ls); init_stream(ls, 8192); s_push_layer(ls, iso_hdr, 8); cap_count = 0; - cap_bytes = 0; #if 0 out_uint16_le(ls, 0); out_uint16_le(ls, 4); cap_count++; - cap_bytes += 4; out_uint16_le(ls, 1); out_uint16_le(ls, 4); cap_count++; - cap_bytes += 4; #endif + out_uint16_le(ls, 100); /* Version capability */ + out_uint16_le(ls, 2 + 2 + 4); + out_uint32_le(ls, CLIENT_INFO_CURRENT_VERSION); + cap_count++; + s_mark_end(ls); len = (int)(ls->end - ls->data); s_pop_layer(ls, iso_hdr); out_uint16_le(ls, 2); /* caps */ out_uint16_le(ls, cap_count); /* num caps */ - out_uint32_le(ls, cap_bytes); /* caps len after header */ + out_uint32_le(ls, len - 8); /* caps len after header */ rv = rdpClientConSend(dev, clientCon, ls->data, len); @@ -1121,6 +1122,8 @@ rdpClientConProcessMsgClientInfo(rdpPtr dev, rdpClientCon *clientCon) memcpy(&(clientCon->client_info), s->p - 4, bytes); clientCon->client_info.size = bytes; + // This shouldn't happen - xrdp should check the version we send it + // before sending client info. if (clientCon->client_info.version != CLIENT_INFO_CURRENT_VERSION) { LLOGLN(0, ("expected xrdp client_info version %d, got %d",