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

Fix off-by-one errors in monitor resize logic #2219

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
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
31 changes: 13 additions & 18 deletions libxrdp/libxrdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1881,29 +1881,29 @@ libxrdp_process_monitor_stream(struct stream *s,
* 200 <= width <= 8192 and must not be odd.
* Ex: in_uint32_le(s, monitor_layout->width);
*/
in_uint32_le(s, monitor_layout->right);
if (monitor_layout->right
> CLIENT_MONITOR_DATA_MAXIMUM_VIRTUAL_MONITOR_WIDTH
|| monitor_layout->right
< CLIENT_MONITOR_DATA_MINIMUM_VIRTUAL_MONITOR_WIDTH
|| monitor_layout->right % 2 != 0)
int width;
in_uint32_le(s, width);
if (width > CLIENT_MONITOR_DATA_MAXIMUM_VIRTUAL_MONITOR_WIDTH ||
width < CLIENT_MONITOR_DATA_MINIMUM_VIRTUAL_MONITOR_WIDTH ||
width % 2 != 0)
{
return SEC_PROCESS_MONITORS_ERR_INVALID_MONITOR;
}
monitor_layout->right = monitor_layout->left + width - 1;

/* Per spec (2.2.2.2.1 DISPLAYCONTROL_MONITOR_LAYOUT),
* this is the height.
* 200 <= height <= 8192
* Ex: in_uint32_le(s, monitor_layout->height);
*/
in_uint32_le(s, monitor_layout->bottom);
if (monitor_layout->bottom
> CLIENT_MONITOR_DATA_MAXIMUM_VIRTUAL_MONITOR_HEIGHT
|| monitor_layout->bottom
< CLIENT_MONITOR_DATA_MINIMUM_VIRTUAL_MONITOR_HEIGHT)
int height;
in_uint32_le(s, height);
if (height > CLIENT_MONITOR_DATA_MAXIMUM_VIRTUAL_MONITOR_HEIGHT ||
height < CLIENT_MONITOR_DATA_MINIMUM_VIRTUAL_MONITOR_HEIGHT)
{
return SEC_PROCESS_MONITORS_ERR_INVALID_MONITOR;
}
monitor_layout->bottom = monitor_layout->top + height - 1;

in_uint32_le(s, monitor_layout->physical_width);
in_uint32_le(s, monitor_layout->physical_height);
Expand Down Expand Up @@ -2001,19 +2001,14 @@ libxrdp_process_monitor_stream(struct stream *s,
monitor_layout->flags,
monitor_layout->left,
monitor_layout->top,
monitor_layout->right,
monitor_layout->bottom,
width,
height,
monitor_layout->physical_width,
monitor_layout->physical_height,
monitor_layout->orientation,
monitor_layout->desktop_scale_factor,
monitor_layout->device_scale_factor);

monitor_layout->right =
monitor_layout->left + monitor_layout->right;
monitor_layout->bottom =
monitor_layout->top + monitor_layout->bottom;

if (monitor_layout->flags == DISPLAYCONTROL_MONITOR_PRIMARY)
{
monitor_layout->is_primary = TS_MONITOR_PRIMARY;
Expand Down
Loading