From 4ab49bc276b25bdbe561c5eee0d38d9fa1913ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Thu, 9 Jan 2020 00:28:16 +0100 Subject: [PATCH] [BLUE] IOCTL_CONSOLE_DRAW: Fix ConsoleDraw.SizeX/Y boundary checks. Always set the cursor position before possibly refreshing screen. --- drivers/setup/blue/blue.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/setup/blue/blue.c b/drivers/setup/blue/blue.c index 1a911689cef..2ca5c70389c 100644 --- a/drivers/setup/blue/blue.c +++ b/drivers/setup/blue/blue.c @@ -1455,6 +1455,14 @@ ScrIoControl( break; } + Irp->IoStatus.Information = 0; + + /* Set the cursor position, clipping it to the screen */ + DeviceExtension->CursorX = min(max(ConsoleDraw.CursorX, 0), DeviceExtension->Columns - 1); + DeviceExtension->CursorY = min(max(ConsoleDraw.CursorY, 0), DeviceExtension->Rows - 1); + if (DeviceExtension->Enabled) + ScrSetCursor(DeviceExtension); + // TODO: For the moment if the ConsoleDraw rectangle has borders // out of the screen-buffer we just bail out. Would it be better // to actually clip the rectangle within its borders instead? @@ -1464,8 +1472,8 @@ ScrIoControl( Status = STATUS_SUCCESS; break; } - if ( ConsoleDraw.SizeX >= DeviceExtension->Columns - ConsoleDraw.X || - ConsoleDraw.SizeY >= DeviceExtension->Rows - ConsoleDraw.Y ) + if ( ConsoleDraw.SizeX > DeviceExtension->Columns - ConsoleDraw.X || + ConsoleDraw.SizeY > DeviceExtension->Rows - ConsoleDraw.Y ) { Status = STATUS_SUCCESS; break; @@ -1489,13 +1497,6 @@ ScrIoControl( } } - /* Set the cursor position, clipping it to the screen */ - DeviceExtension->CursorX = min(max(ConsoleDraw.CursorX, 0), DeviceExtension->Columns - 1); - DeviceExtension->CursorY = min(max(ConsoleDraw.CursorY, 0), DeviceExtension->Rows - 1); - if (DeviceExtension->Enabled) - ScrSetCursor(DeviceExtension); - - Irp->IoStatus.Information = 0; Status = STATUS_SUCCESS; break; }