hidclass.sys: Enforce POLL_FREQUENCY_MSEC value range.

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 2021-08-16 10:07:48 +02:00 committed by Alexandre Julliard
parent f68923dca0
commit 286999a9ea
2 changed files with 26 additions and 10 deletions

View file

@ -535,13 +535,8 @@ NTSTATUS WINAPI pdo_ioctl(DEVICE_OBJECT *device, IRP *irp)
break;
}
poll_interval = *(ULONG *)irp->AssociatedIrp.SystemBuffer;
if (poll_interval <= MAX_POLL_INTERVAL_MSEC)
{
ext->u.pdo.poll_interval = poll_interval;
irp->IoStatus.Status = STATUS_SUCCESS;
}
else
irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
if (poll_interval) ext->u.pdo.poll_interval = min(poll_interval, MAX_POLL_INTERVAL_MSEC);
irp->IoStatus.Status = STATUS_SUCCESS;
break;
}
case IOCTL_HID_GET_PRODUCT_STRING:

View file

@ -2833,7 +2833,21 @@ static void test_hid_device(DWORD report_id, DWORD polled)
poll_freq = 500;
SetLastError(0xdeadbeef);
ret = sync_ioctl(file, IOCTL_HID_SET_POLL_FREQUENCY_MSEC, &poll_freq, sizeof(ULONG), NULL, &out_len);
ok(ret, "IOCTL_HID_GET_POLL_FREQUENCY_MSEC failed last error %u\n", GetLastError());
ok(ret, "IOCTL_HID_SET_POLL_FREQUENCY_MSEC failed last error %u\n", GetLastError());
ok(out_len == 0, "got out_len %u, expected 0\n", out_len);
out_len = 0;
poll_freq = 10001;
SetLastError(0xdeadbeef);
ret = sync_ioctl(file, IOCTL_HID_SET_POLL_FREQUENCY_MSEC, &poll_freq, sizeof(ULONG), NULL, &out_len);
ok(ret, "IOCTL_HID_SET_POLL_FREQUENCY_MSEC failed last error %u\n", GetLastError());
ok(out_len == 0, "got out_len %u, expected 0\n", out_len);
out_len = 0;
poll_freq = 0;
SetLastError(0xdeadbeef);
ret = sync_ioctl(file, IOCTL_HID_SET_POLL_FREQUENCY_MSEC, &poll_freq, sizeof(ULONG), NULL, &out_len);
ok(ret, "IOCTL_HID_SET_POLL_FREQUENCY_MSEC failed last error %u\n", GetLastError());
ok(out_len == 0, "got out_len %u, expected 0\n", out_len);
out_len = sizeof(ULONG);
@ -2841,14 +2855,21 @@ static void test_hid_device(DWORD report_id, DWORD polled)
ret = sync_ioctl(file, IOCTL_HID_GET_POLL_FREQUENCY_MSEC, NULL, 0, &poll_freq, &out_len);
ok(ret, "IOCTL_HID_GET_POLL_FREQUENCY_MSEC failed last error %u\n", GetLastError());
ok(out_len == sizeof(ULONG), "got out_len %u, expected sizeof(ULONG)\n", out_len);
ok(poll_freq == 500, "got poll_freq %u, expected 100\n", poll_freq);
ok(poll_freq == 10000, "got poll_freq %u, expected 10000\n", poll_freq);
out_len = 0;
poll_freq = 500;
SetLastError(0xdeadbeef);
ret = sync_ioctl(file, IOCTL_HID_SET_POLL_FREQUENCY_MSEC, &poll_freq, sizeof(ULONG), NULL, &out_len);
ok(ret, "IOCTL_HID_SET_POLL_FREQUENCY_MSEC failed last error %u\n", GetLastError());
ok(out_len == 0, "got out_len %u, expected 0\n", out_len);
out_len = sizeof(ULONG);
SetLastError(0xdeadbeef);
ret = sync_ioctl(async_file, IOCTL_HID_GET_POLL_FREQUENCY_MSEC, NULL, 0, &poll_freq, &out_len);
ok(ret, "IOCTL_HID_GET_POLL_FREQUENCY_MSEC failed last error %u\n", GetLastError());
ok(out_len == sizeof(ULONG), "got out_len %u, expected sizeof(ULONG)\n", out_len);
ok(poll_freq == 500, "got poll_freq %u, expected 100\n", poll_freq);
ok(poll_freq == 500, "got poll_freq %u, expected 500\n", poll_freq);
}
test_hidp(file, async_file, report_id, polled);