Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V0.10] Remove xrdp_sec_in_mcs_data() function #3273

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 21 additions & 101 deletions libxrdp/xrdp_sec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,6 @@ xrdp_sec_process_mcs_data_CS_CORE(struct xrdp_sec *self, struct stream *s)
int highColorDepth;
int supportedColorDepths;
int earlyCapabilityFlags;
char clientName[INFO_CLIENT_NAME_BYTES / 2] = { '\0' };

UNUSED_VAR(version);
struct xrdp_client_info *client_info = &self->rdp_layer->client_info;
Expand Down Expand Up @@ -1756,35 +1755,44 @@ xrdp_sec_process_mcs_data_CS_CORE(struct xrdp_sec *self, struct stream *s)
break;
}
in_uint8s(s, 2); /* SASSequence */
in_uint8s(s, 4); /* keyboardLayout */
in_uint8s(s, 4); /* clientBuild */
in_uint32_le(s, client_info->keylayout);
in_uint32_le(s, client_info->build);

/* clientName
*
* 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,
clientName, sizeof(clientName));
client_info->hostname,
sizeof(client_info->hostname));
in_uint8s(s, 2); /* See above */
LOG(LOG_LEVEL_INFO, "Connected client computer name: %s", clientName);
in_uint8s(s, 4); /* keyboardType */
in_uint8s(s, 4); /* keyboardSubType */
LOG(LOG_LEVEL_INFO, "Connected client computer name: %s",
client_info->hostname);
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 */
in_uint8s(s, 64); /* imeFileName */
LOG_DEVEL(LOG_LEVEL_TRACE, "Received [MS-RDPBCGR] TS_UD_CS_CORE "
"<Required fields> version %08x, desktopWidth %d, "
"desktopHeight %d, colorDepth %s, SASSequence (ignored), "
"keyboardLayout (ignored), clientBuild (ignored), "
"clientName %s, keyboardType (ignored), "
"keyboardSubType (ignored), keyboardFunctionKey (ignored), "
"keyboardLayout 0x%8.8x, clientBuild %d, "
"clientName %s, keyboardType 0x%8.8x, "
"keyboardSubType 0x%8.8x, keyboardFunctionKey (ignored), "
"imeFileName (ignored)",
version,
client_info->display_sizes.session_width,
client_info->display_sizes.session_height,
(colorDepth == 0xca00 ? "RNS_UD_COLOR_4BPP" :
colorDepth == 0xca01 ? "RNS_UD_COLOR_8BPP" : "unknown"),
clientName);
(colorDepth == RNS_UD_COLOR_4BPP ? "RNS_UD_COLOR_4BPP" :
colorDepth == RNS_UD_COLOR_8BPP ? "RNS_UD_COLOR_8BPP" :
"unknown"),
client_info->keylayout,
client_info->build,
client_info->hostname,
client_info->keyboard_type,
client_info->keyboard_subtype);

xrdp_load_keyboard_layout(client_info);

/* TS_UD_CS_CORE optional fields */
if (!s_check_rem(s, 2))
Expand Down Expand Up @@ -2420,88 +2428,6 @@ xrdp_sec_process_mcs_data(struct xrdp_sec *self)
return 0;
}

/*****************************************************************************/
/* Process the mcs client data [ITU T.124] ConferenceCreateRequest userData field
as a [MS-RDPBCGR] TS_UD_CS_CORE struct */
/* TODO: why does this method parse the strust from back to front (resetting
after each field) instead of from front to back like the rest of the parsing
code? */
/* TODO: why does this method exist when the same struct is parsed in
xrdp_sec_process_mcs_data_CS_CORE and there does not seem to be any
dependencies preventing a call to that function. */
/* TODO: this is a brittle function that assumes field offsets in the stream
instead of parsing the variable length fields of [ITU T.124] ConferenceCreateRequest */
static int
xrdp_sec_in_mcs_data(struct xrdp_sec *self)
{
struct stream *s = (struct stream *)NULL;
struct xrdp_client_info *client_info = (struct xrdp_client_info *)NULL;

client_info = &(self->rdp_layer->client_info);
s = &(self->client_mcs_data);
/* get hostname, it's unicode */
s->p = s->data;
if (!s_check_rem_and_log(s, 47, "Parsing [ITU T.124] ConferenceCreateRequest"))
{
return 1;
}
in_uint8s(s, 47); /* skip [ITU T.124] ConferenceCreateRequest up to the
userData field, and skip [MS-RDPBCGR] TS_UD_CS_CORE
up to the clientName field */
if (!s_check_rem_and_log(s, INFO_CLIENT_NAME_BYTES,
"Parsing [MS-RDPBCGR] TS_UD_CS_CORE clientName"))
{
return 1;
}
in_utf16_le_fixed_as_utf8(s, (INFO_CLIENT_NAME_BYTES - 2) / 2,
client_info->hostname,
sizeof(client_info->hostname));
in_uint8s(s, 2); /* Ignored - terminator for full-size clientName */

/* get build */
s->p = s->data;
if (!s_check_rem_and_log(s, 43 + 4, "Parsing [MS-RDPBCGR] TS_UD_CS_CORE clientBuild"))
{
return 1;
}
in_uint8s(s, 43);
in_uint32_le(s, client_info->build); /* [MS-RDPBCGR] TS_UD_CS_CORE clientBuild */
/* get keylayout */
s->p = s->data;
if (!s_check_rem_and_log(s, 39 + 4, "Parsing [MS-RDPBCGR] TS_UD_CS_CORE keyboardLayout"))
{
return 1;
}
in_uint8s(s, 39);
in_uint32_le(s, client_info->keylayout); /* [MS-RDPBCGR] TS_UD_CS_CORE keyboardLayout */
/* get keyboard type / subtype */
s->p = s->data;
if (!s_check_rem_and_log(s, 79 + 8, "Parsing [MS-RDPBCGR] TS_UD_CS_CORE keyboardType"))
{
return 1;
}
in_uint8s(s, 79);
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 */
LOG_DEVEL(LOG_LEVEL_TRACE, "Received [MS-RDPBCGR] TS_UD_CS_CORE "
"<Required fields> version (ignored), desktopWidth (ignored), "
"desktopHeight (ignored), colorDepth (ignored), SASSequence (ignored), "
"keyboardLayout 0x%8.8x, clientBuild %d, "
"clientName %s, keyboardType 0x%8.8x, "
"keyboardSubType 0x%8.8x, keyboardFunctionKey (ignored), "
"imeFileName (ignored)",
client_info->keylayout,
client_info->build,
client_info->hostname,
client_info->keyboard_type,
client_info->keyboard_subtype);

xrdp_load_keyboard_layout(client_info);
s->p = s->data;

return 0;
}

/*****************************************************************************/
/* returns error */
int
Expand Down Expand Up @@ -2686,12 +2612,6 @@ xrdp_sec_incoming(struct xrdp_sec *self)
self->server_mcs_data.data,
(int)(self->server_mcs_data.end - self->server_mcs_data.data));

if (xrdp_sec_in_mcs_data(self) != 0)
{
LOG(LOG_LEVEL_ERROR, "xrdp_sec_incoming: xrdp_sec_in_mcs_data failed");
return 1;
}

return 0;
}

Expand Down