@@ -1134,7 +1134,7 @@ libxrdp_orders_send_font(struct xrdp_session *session,
11341134 * to a single monitor */
11351135int EXPORT_CC
11361136libxrdp_reset (struct xrdp_session * session ,
1137- int width , int height , int bpp )
1137+ unsigned int width , unsigned int height , int bpp )
11381138{
11391139 if (session -> client_info != 0 )
11401140 {
@@ -1147,18 +1147,18 @@ libxrdp_reset(struct xrdp_session *session,
11471147 }
11481148
11491149 /* if same (and only one monitor on client) don't need to do anything */
1150- if (client_info -> width == width &&
1151- client_info -> height == height &&
1150+ if (client_info -> display_sizes . session_width == width &&
1151+ client_info -> display_sizes . session_height == height &&
11521152 client_info -> bpp == bpp &&
1153- (client_info -> monitorCount == 0 || client_info -> multimon == 0 ))
1153+ (client_info -> display_sizes . monitorCount == 0 || client_info -> multimon == 0 ))
11541154 {
11551155 return 0 ;
11561156 }
11571157
1158- client_info -> width = width ;
1159- client_info -> height = height ;
1158+ client_info -> display_sizes .session_width = width ;
1159+ client_info -> display_sizes .session_height = height ;
1160+ client_info -> display_sizes .monitorCount = 0 ;
11601161 client_info -> bpp = bpp ;
1161- client_info -> monitorCount = 0 ;
11621162 client_info -> multimon = 0 ;
11631163 }
11641164 else
@@ -1908,8 +1908,39 @@ libxrdp_process_monitor_stream(struct stream *s,
19081908 in_uint32_le (s , monitor_layout -> physical_width );
19091909 in_uint32_le (s , monitor_layout -> physical_height );
19101910
1911+ /* Per spec (2.2.2.2.1 DISPLAYCONTROL_MONITOR_LAYOUT),
1912+ * if EITHER physical_width or physical_height are
1913+ * out of range, BOTH must be ignored.
1914+ */
1915+ if (monitor_layout -> physical_width > 10000
1916+ || monitor_layout -> physical_width < 10 )
1917+ {
1918+ LOG (LOG_LEVEL_WARNING , "libxrdp_process_monitor_stream:"
1919+ " physical_width is not within valid range."
1920+ " Setting physical_width to 0mm,"
1921+ " Setting physical_height to 0mm,"
1922+ " physical_width was: %d" ,
1923+ monitor_layout -> physical_width );
1924+ monitor_layout -> physical_width = 0 ;
1925+ monitor_layout -> physical_height = 0 ;
1926+ }
1927+
1928+ if (monitor_layout -> physical_height > 10000
1929+ || monitor_layout -> physical_height < 10 )
1930+ {
1931+ LOG (LOG_LEVEL_WARNING , "libxrdp_process_monitor_stream:"
1932+ " physical_height is not within valid range."
1933+ " Setting physical_width to 0mm,"
1934+ " Setting physical_height to 0mm,"
1935+ " physical_height was: %d" ,
1936+ monitor_layout -> physical_height );
1937+ monitor_layout -> physical_width = 0 ;
1938+ monitor_layout -> physical_height = 0 ;
1939+ }
1940+
19111941 in_uint32_le (s , monitor_layout -> orientation );
1912- switch (monitor_layout -> orientation ) {
1942+ switch (monitor_layout -> orientation )
1943+ {
19131944 case ORIENTATION_LANDSCAPE :
19141945 case ORIENTATION_PORTRAIT :
19151946 case ORIENTATION_LANDSCAPE_FLIPPED :
@@ -1918,21 +1949,47 @@ libxrdp_process_monitor_stream(struct stream *s,
19181949 default :
19191950 LOG (LOG_LEVEL_WARNING , "libxrdp_process_monitor_stream:"
19201951 " Orientation is not one of %d, %d, %d, or %d."
1921- " Value was %d and ignored." ,
1952+ " Value was %d and ignored and set to default value of LANDSCAPE ." ,
19221953 ORIENTATION_LANDSCAPE ,
19231954 ORIENTATION_PORTRAIT ,
19241955 ORIENTATION_LANDSCAPE_FLIPPED ,
19251956 ORIENTATION_PORTRAIT_FLIPPED ,
19261957 monitor_layout -> orientation );
1958+ monitor_layout -> orientation = ORIENTATION_LANDSCAPE ;
19271959 }
19281960
19291961 in_uint32_le (s , monitor_layout -> desktop_scale_factor );
1962+ if (monitor_layout -> desktop_scale_factor < 100
1963+ || monitor_layout -> desktop_scale_factor > 500
1964+ || (monitor_layout -> desktop_scale_factor != 100
1965+ && monitor_layout -> desktop_scale_factor != 140
1966+ && monitor_layout -> desktop_scale_factor != 180 ))
1967+ {
1968+ LOG (LOG_LEVEL_WARNING , "libxrdp_process_monitor_stream:"
1969+ " desktop_scale_factor is not within valid range. Assuming 100."
1970+ " Value was: %d" ,
1971+ monitor_layout -> desktop_scale_factor );
1972+ monitor_layout -> desktop_scale_factor = 100 ;
1973+ }
1974+
19301975 in_uint32_le (s , monitor_layout -> device_scale_factor );
1976+ if (monitor_layout -> device_scale_factor < 100
1977+ || monitor_layout -> device_scale_factor > 500
1978+ || (monitor_layout -> device_scale_factor != 100
1979+ && monitor_layout -> device_scale_factor != 140
1980+ && monitor_layout -> device_scale_factor != 180 ))
1981+ {
1982+ LOG (LOG_LEVEL_WARNING , "libxrdp_process_monitor_stream:"
1983+ " device_scale_factor is not within valid range. Assuming 100."
1984+ " Value was: %d" ,
1985+ monitor_layout -> device_scale_factor );
1986+ monitor_layout -> device_scale_factor = 100 ;
1987+ }
19311988
19321989 /*
19331990 * 2.2.2.2.1 DISPLAYCONTROL_MONITOR_LAYOUT
19341991 */
1935- LOG_DEVEL (LOG_LEVEL_TRACE , "libxrdp_process_monitor_stream:"
1992+ LOG_DEVEL (LOG_LEVEL_INFO , "libxrdp_process_monitor_stream:"
19361993 " Received [MS-RDPEDISP] 2.2.2.2.1"
19371994 " DISPLAYCONTROL_MONITOR_LAYOUT_PDU"
19381995 ".DISPLAYCONTROL_MONITOR_LAYOUT"
0 commit comments