Module: wine Branch: master Commit: 85d8d1390467147fca416236fd50bb6ea2e2c8e4 URL: https://source.winehq.org/git/wine.git/?a=commit;h=85d8d1390467147fca416236f...
Author: Rémi Bernon rbernon@codeweavers.com Date: Tue Sep 10 19:02:31 2019 +0200
user32: Add parameter validation for RegisterRawInputDevices.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/user32/rawinput.c | 11 +++++++++++ dlls/user32/tests/rawinput.c | 3 --- 2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 49cf9f73a0..94cf7a9a5d 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -261,9 +261,20 @@ BOOL WINAPI DECLSPEC_HOTPATCH RegisterRawInputDevices(RAWINPUTDEVICE *devices, U if (size != sizeof(*devices)) { WARN("Invalid structure size %u.\n", size); + SetLastError(ERROR_INVALID_PARAMETER); return FALSE; }
+ for (i = 0; i < device_count; ++i) + { + if ((devices[i].dwFlags & RIDEV_REMOVE) && + (devices[i].hwndTarget != NULL)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + } + if (!(d = HeapAlloc( GetProcessHeap(), 0, device_count * sizeof(*d) ))) return FALSE;
for (i = 0; i < device_count; ++i) diff --git a/dlls/user32/tests/rawinput.c b/dlls/user32/tests/rawinput.c index 4aa2a162f4..f4c8eb6738 100644 --- a/dlls/user32/tests/rawinput.c +++ b/dlls/user32/tests/rawinput.c @@ -49,7 +49,6 @@ static void test_RegisterRawInputDevices(void) SetLastError(0xdeadbeef); res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), 0); ok(res == FALSE, "RegisterRawInputDevices succeeded\n"); - todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned %08x\n", GetLastError());
SetLastError(0xdeadbeef); @@ -64,9 +63,7 @@ static void test_RegisterRawInputDevices(void)
SetLastError(0xdeadbeef); res = RegisterRawInputDevices(raw_devices, ARRAY_SIZE(raw_devices), sizeof(RAWINPUTDEVICE)); - todo_wine ok(res == FALSE, "RegisterRawInputDevices succeeded\n"); - todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "RegisterRawInputDevices returned %08x\n", GetLastError());
raw_devices[0].hwndTarget = 0;