user32: Add parameter validation for RegisterRawInputDevices.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2019-09-10 19:02:31 +02:00 committed by Alexandre Julliard
parent d8b222548d
commit 85d8d13904
2 changed files with 11 additions and 3 deletions

View File

@ -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)

View File

@ -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;