@@ -1744,19 +1744,31 @@ xrdp_sec_process_mcs_data_CS_CORE(struct xrdp_sec* self, struct stream* s)
1744
1744
{
1745
1745
return 0 ;
1746
1746
}
1747
- in_uint8s (s , 4 ); /* desktopPhysicalWidth */
1747
+ in_uint32_le (s , self -> rdp_layer -> client_info . physical_width ); /* desktopPhysicalWidth */
1748
1748
1749
1749
if (!s_check_rem (s , 4 ))
1750
1750
{
1751
1751
return 0 ;
1752
1752
}
1753
- in_uint8s (s , 4 ); /* desktopPhysicalHeight */
1753
+ in_uint32_le (s , self -> rdp_layer -> client_info . physical_height ); /* desktopPhysicalHeight */
1754
1754
1755
1755
if (!s_check_rem (s , 2 ))
1756
1756
{
1757
1757
return 0 ;
1758
1758
}
1759
- in_uint8s (s , 2 ); /* reserved */
1759
+ in_uint16_le (s , self -> rdp_layer -> client_info .orientation ); /* desktopOrientation */
1760
+
1761
+ if (!s_check_rem (s , 4 ))
1762
+ {
1763
+ return 0 ;
1764
+ }
1765
+ in_uint32_le (s , self -> rdp_layer -> client_info .desktop_scale_factor );
1766
+
1767
+ if (!s_check_rem (s , 4 ))
1768
+ {
1769
+ return 0 ;
1770
+ }
1771
+ in_uint32_le (s , self -> rdp_layer -> client_info .device_scale_factor );
1760
1772
1761
1773
return 0 ;
1762
1774
}
@@ -2046,6 +2058,79 @@ xrdp_sec_process_mcs_data_monitors(struct xrdp_sec *self, struct stream *s)
2046
2058
return 0 ;
2047
2059
}
2048
2060
2061
+ static int
2062
+ xrdp_sec_process_msc_data_monitorex (struct xrdp_sec * self , struct stream * s )
2063
+ {
2064
+ uint32_t flags ;
2065
+ uint32_t size ;
2066
+ uint32_t count ;
2067
+ uint32_t index ;
2068
+ struct xrdp_client_info * client_info = & self -> rdp_layer -> client_info ;
2069
+
2070
+ if (client_info -> multimon != 1 ) {
2071
+ LLOGLN (0 , ("[INFO] xrdp_sec_process_msc_data_monitorex: multimon is not "
2072
+ "allowed, skipping" ));
2073
+ return 0 ;
2074
+ }
2075
+ in_uint32_le (s , flags );
2076
+ if (flags != 0 ) {
2077
+ LLOGLN (0 , ("[ERROR] xrdp_sec_process_msc_data_monitorex: flags MUST be "
2078
+ "zero, detected: 0x%x" , flags ));
2079
+ return 1 ;
2080
+ }
2081
+ in_uint32_le (s , size );
2082
+ if (size != 20 ) {
2083
+ LLOGLN (0 , ("[ERROR] xrdp_sec_process_msc_data_monitorex: monitorAttributeSize MUST be "
2084
+ "20, detected: %u" , size ));
2085
+ return 1 ;
2086
+ }
2087
+ in_uint32_le (s , count );
2088
+ if (count > 16 )
2089
+ {
2090
+ LLOGLN (0 , ("[ERROR] xrdp_sec_process_msc_data_monitorex: max allowed "
2091
+ "monitors is 16, detected: %d" , count ));
2092
+ return 1 ;
2093
+ }
2094
+
2095
+ for (index = 0 ; index < count ; index ++ )
2096
+ {
2097
+ in_uint32_le (s , client_info -> minfo [index ].physical_width );
2098
+ if (client_info -> minfo [index ].physical_width < 10 ||
2099
+ client_info -> minfo [index ].physical_width > 10000 ) {
2100
+ LLOGLN (0 , ("[INFO] xrdp_sec_process_msc_data_monitorex: ignore "
2101
+ "invalid physical_width: %d" ,
2102
+ client_info -> minfo [index ].physical_width ));
2103
+ client_info -> minfo [index ].physical_width = 0 ;
2104
+ }
2105
+ in_uint32_le (s , client_info -> minfo [index ].physical_height );
2106
+ if (client_info -> minfo [index ].physical_height < 10 ||
2107
+ client_info -> minfo [index ].physical_height > 10000 ) {
2108
+ LLOGLN (0 , ("[INFO] xrdp_sec_process_msc_data_monitorex: ignore "
2109
+ "invalid physical_height: %d" ,
2110
+ client_info -> minfo [index ].physical_height ));
2111
+ client_info -> minfo [index ].physical_height = 0 ;
2112
+ }
2113
+ in_uint32_le (s , client_info -> minfo [index ].orientation );
2114
+ switch (client_info -> minfo [index ].orientation ) {
2115
+ case 0 :
2116
+ case 90 :
2117
+ case 180 :
2118
+ case 270 :
2119
+ break ;
2120
+ default :
2121
+ LLOGLN (0 , ("[INFO] xrdp_sec_process_msc_data_monitorex: ignore "
2122
+ "invalid orientation: %d" ,
2123
+ client_info -> minfo [index ].orientation ));
2124
+ client_info -> minfo [index ].orientation = 0 ;
2125
+ break ;
2126
+ }
2127
+ in_uint32_le (s , client_info -> minfo [index ].desktop_scale_factor );
2128
+ in_uint32_le (s , client_info -> minfo [index ].device_scale_factor );
2129
+ }
2130
+
2131
+ return 0 ;
2132
+ }
2133
+
2049
2134
/*****************************************************************************/
2050
2135
/* process client mcs data, we need some things in here to create the server
2051
2136
mcs data */
@@ -2108,9 +2193,14 @@ xrdp_sec_process_mcs_data(struct xrdp_sec *self)
2108
2193
{
2109
2194
return 1 ;
2110
2195
}
2196
+ break ;
2197
+ case SEC_TAG_CLI_MONITOR_EX :
2198
+ if (xrdp_sec_process_msc_data_monitorex (self , s ) != 0 )
2199
+ {
2200
+ return 1 ;
2201
+ }
2111
2202
break ;
2112
2203
/* CS_MCS_MSGCHANNEL 0xC006
2113
- CS_MONITOR_EX 0xC008
2114
2204
CS_MULTITRANSPORT 0xC00A
2115
2205
SC_CORE 0x0C01
2116
2206
SC_SECURITY 0x0C02
0 commit comments