https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4ab49bc276b25bdbe561c5eee0d38d9fa1913ddb

commit 4ab49bc276b25bdbe561c5eee0d38d9fa1913ddb
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Thu Jan 9 00:28:16 2020 +0100
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Sun Dec 27 00:51:42 2020 +0100

    [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;
         }

Reply via email to