[PATCH 2/2] user32: Reject invalid length in SetWindowPlacement.

Esme Povirk esme at codeweavers.com
Wed Jan 26 14:57:35 CST 2022


Signed-off-by: Esme Povirk <esme at codeweavers.com>
---
 dlls/user32/tests/win.c | 2 --
 dlls/user32/winpos.c    | 5 +++++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index b1ef97c01d6..60b19333978 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -12092,10 +12092,8 @@ static void test_window_placement(void)
     wp.length = 0;
     SetLastError(0xdeadbeef);
     ret = SetWindowPlacement(hwnd, &wp);
-todo_wine {
     ok(!ret, "SetWindowPlacement should have failed\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError());
-}
 
     DestroyWindow(hwnd);
 }
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index ff23206b395..eeae9337c33 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -1530,6 +1530,11 @@ BOOL WINAPI SetWindowPlacement( HWND hwnd, const WINDOWPLACEMENT *wpl )
 {
     UINT flags = PLACE_MAX | PLACE_RECT;
     if (!wpl) return FALSE;
+    if (wpl->length != sizeof(*wpl))
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
     if (wpl->flags & WPF_SETMINPOSITION) flags |= PLACE_MIN;
     return WINPOS_SetPlacement( hwnd, wpl, flags );
 }
-- 
2.30.2




More information about the wine-devel mailing list