Commit 286999a9 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

hidclass.sys: Enforce POLL_FREQUENCY_MSEC value range.

parent f68923dc
......@@ -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:
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment