From ad9882f0438008de26d67c56b92a6a8ea0b7aee0 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 72556ca..1111446 100644 --- a/module/rdpClientCon.c +++ b/module/rdpClientCon.c @@ -638,33 +638,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); @@ -1124,6 +1125,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",