From: Esme Povirk Subject: [PATCH 2/2] user32: Reject invalid length in SetWindowPlacement. Message-Id: <20220126205735.394331-2-esme@codeweavers.com> Date: Wed, 26 Jan 2022 14:57:35 -0600 In-Reply-To: <20220126205735.394331-1-esme@codeweavers.com> References: <20220126205735.394331-1-esme@codeweavers.com> Signed-off-by: Esme Povirk --- 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