Rename client_info hostname to client_name

This name better matches the name from [MS-RDPBCGR]. Also, the size
of the UTF-8 buffer allocated for the client name is not large
enough for some of the names which could potentially be passed across
in UTF-16 from the client.
This commit is contained in:
matt335672
2025-07-17 12:06:32 +01:00
parent db50a27089
commit ac95cdffc3
5 changed files with 23 additions and 11 deletions
+1 -1
View File
@@ -146,7 +146,7 @@ struct xrdp_client_info
int op2; /* use smaller bitmap header in bitmap cache */
int desktop_cache;
int use_compact_packets; /* rdp5 smaller packets */
char hostname[32];
char client_name[INFO_CLIENT_NAME_BYTES_UTF8];
int build;
int keylayout;
char username[INFO_CLIENT_MAX_CB_LEN];
+13 -1
View File
@@ -51,8 +51,20 @@
*/
#define MAX_PEER_DESCSTRLEN (46 + 2 + 1 + 5)
#define INFO_CLIENT_NAME_BYTES 32
/*
* Number of bytes used to send a client name in the client core data
* ([MS-RDPBCGR] 2.2.1.3.2). This is 15 characters plus a terminator in
* UTF-16
*/
#define INFO_CLIENT_NAME_BYTES_UTF16 ((15 + 1) * 2)
/*
* Number of bytes needed to store the client name as UTF-8. It is assumed
* that the 15 Unicode characters in the name all occupy BMP codepoints
* between U+0800 and U+FFFF. These codepoints all need three octets
* in UTF-8
*/
#define INFO_CLIENT_NAME_BYTES_UTF8 ((3 * 15) + 1)
/**
* Maximum length of a string including the mandatory null terminator
* [MS-RDPBCGR] TS_INFO_PACKET(2.2.1.11.1.1)
+6 -6
View File
@@ -1477,7 +1477,7 @@ xrdp_sec_process_mcs_data_CS_CORE(struct xrdp_sec *self, struct stream *s)
2 + 2 + /* desktopWidth + desktopHeight */ \
2 + 2 + /* colorDepth + SASSequence */ \
4 + /* keyboardLayout */ \
4 + INFO_CLIENT_NAME_BYTES + /* clientBuild + clientName */ \
4 + INFO_CLIENT_NAME_BYTES_UTF16 + /* clientBuild + clientName */ \
4 + 4 + 4 + /* keyboardType + keyboardSubType + keyboardFunctionKey */ \
64 + /* imeFileName */ \
0)
@@ -1523,12 +1523,12 @@ xrdp_sec_process_mcs_data_CS_CORE(struct xrdp_sec *self, struct stream *s)
* This should be null-terminated. Allow for the possibility it
* isn't by ignoring the last two bytes and treating them as a
* terminator anyway */
in_utf16_le_fixed_as_utf8(s, (INFO_CLIENT_NAME_BYTES - 2) / 2,
client_info->hostname,
sizeof(client_info->hostname));
in_utf16_le_fixed_as_utf8(s, (INFO_CLIENT_NAME_BYTES_UTF16 - 2) / 2,
client_info->client_name,
sizeof(client_info->client_name));
in_uint8s(s, 2); /* See above */
LOG(LOG_LEVEL_INFO, "Connected client computer name: %s",
client_info->hostname);
client_info->client_name);
in_uint32_le(s, client_info->keyboard_type); /* [MS-RDPBCGR] TS_UD_CS_CORE keyboardType */
in_uint32_le(s, client_info->keyboard_subtype); /* [MS-RDPBCGR] TS_UD_CS_CORE keyboardSubType */
in_uint8s(s, 4); /* keyboardFunctionKey */
@@ -1548,7 +1548,7 @@ xrdp_sec_process_mcs_data_CS_CORE(struct xrdp_sec *self, struct stream *s)
"unknown"),
client_info->keylayout,
client_info->build,
client_info->hostname,
client_info->client_name,
client_info->keyboard_type,
client_info->keyboard_subtype);
+1 -1
View File
@@ -611,7 +611,7 @@ lxrdp_set_param(struct mod *mod, const char *name, const char *value)
settings = mod->inst->settings;
if (g_strcmp(name, "hostname") == 0)
if (g_strcmp(name, "client_name") == 0)
{
}
else if (g_strcmp(name, "ip") == 0)
+2 -2
View File
@@ -5342,8 +5342,8 @@ xrdp_mm_setup_mod2(struct xrdp_mm *self)
self->mod->mod_set_param(self->mod, "client_info",
(const char *) (self->wm->session->client_info));
name = self->wm->session->client_info->hostname;
self->mod->mod_set_param(self->mod, "hostname", name);
name = self->wm->session->client_info->client_name;
self->mod->mod_set_param(self->mod, "client_name", name);
g_snprintf(text, 255, "%d", self->wm->session->client_info->keylayout);
self->mod->mod_set_param(self->mod, "keylayout", text);
if (guid_is_set(&self->guid))