[PATCH 47/47] Check the range for HIDIOC?USAGES num_values.

Vojtech Pavlik
2004-07-29T14:26:37Z

ChangeSet@1.1859, 2004-07-29 14:13:12+02:00, vojtech@suse.cz
input: Check the range for HIDIOC?USAGES num_values.

Signed-off-by: Vojtech Pavlik <vojtech@suse.cz>

hiddev.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)

===================================================================

diff -Nru a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
--- a/drivers/usb/input/hiddev.c Thu Jul 29 14:38:23 2004
+++ b/drivers/usb/input/hiddev.c Thu Jul 29 14:38:23 2004
@@ -633,14 +633,11 @@
} else if (uref->usage_index >= field->report_count)
goto inval;

- else if ((cmd == HIDIOCGUSAGES ||
- cmd == HIDIOCSUSAGES) &&
- (uref->usage_index + uref_multi->num_values >=
- field->report_count ||
- uref->usage_index + uref_multi->num_values <
- uref->usage_index))
+ else if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
+ (uref_multi->num_values >= HID_MAX_MULTI_USAGES ||
+ uref->usage_index + uref_multi->num_values >= field->report_count ||
+ uref->usage_index + uref_multi->num_values < uref->usage_index))
goto inval;
-
}

switch (cmd) {