Fix sending of monitor layout PDU

From [MS-RCPBCGR] 3.3.5.12.1:-

> ...The contents of this PDU SHOULD NOT be compressed.
>
> This PDU MUST NOT be sent to a client that has not indicated support for
> it by setting the RNS_UD_CS_SUPPORT_MONITOR_LAYOUT_PDU flag (0x0040)
> in the earlyCapabilityFlags field of the Client Core Data (section
> 2.2.1.3.2).

Also, 2.2.12.1 specifies the source channel must be zero.

In testing, a compressed monitor layout PDU causes mstsc.exe
to exit with a protocol error.
This commit is contained in:
matt335672
2024-02-14 12:14:10 +00:00
parent 689269dcde
commit 74598d1cc3
4 changed files with 43 additions and 17 deletions
+12 -9
View File
@@ -48,6 +48,7 @@ xrdp_caps_send_monitorlayout(struct xrdp_rdp *self)
struct stream *s;
uint32_t i;
struct display_size_description *description;
int rv = 0;
make_stream(s);
init_stream(s, 8192);
@@ -74,14 +75,13 @@ xrdp_caps_send_monitorlayout(struct xrdp_rdp *self)
s_mark_end(s);
if (xrdp_rdp_send_data(self, s, 0x37) != 0)
{
free_stream(s);
return 1;
}
// [MS-RDPBCGR]
// - 2.2.12.1 - ...the pduSource field MUST be set to zero.
// - 3.3.5.12.1 - The contents of this PDU SHOULD NOT be compressed
rv = xrdp_rdp_send_data_from_channel(self, s,
PDUTYPE2_MONITOR_LAYOUT_PDU, 0, 0);
free_stream(s);
return 0;
return rv;
}
/*****************************************************************************/
@@ -1337,8 +1337,11 @@ xrdp_caps_send_demand_active(struct xrdp_rdp *self)
return 1;
}
/* send Monitor Layout PDU for dual monitor */
if (self->client_info.display_sizes.monitorCount > 0 &&
/* send Monitor Layout PDU for multi-monitor */
int early_cap_flags = self->client_info.mcs_early_capability_flags;
if ((early_cap_flags & RNS_UD_CS_SUPPORT_MONITOR_LAYOUT_PDU) != 0 &&
self->client_info.display_sizes.monitorCount > 0 &&
self->client_info.multimon == 1)
{
LOG_DEVEL(LOG_LEVEL_TRACE, "xrdp_caps_send_demand_active: sending monitor layout pdu");