Skip to content

Commit

Permalink
HID: picolcd: sanity check report size in raw_event() callback
Browse files Browse the repository at this point in the history
commit 844817e47eef14141cf59b8d5ac08dd11c0a9189 upstream.

The report passed to us from transport driver could potentially be
arbitrarily large, therefore we better sanity-check it so that raw_data
that we hold in picolcd_pending structure are always kept within proper
bounds.

Reported-by: Steven Vittitoe <scvitti@google.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
[lizf: Backported to 3.4: adjust filename]
Signed-off-by: Zefan Li <lizefan@huawei.com>
  • Loading branch information
Jiri Kosina authored and lizf-os committed Sep 25, 2014
1 parent e115f02 commit e78c127
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/hid/hid-picolcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2370,6 +2370,12 @@ static int picolcd_raw_event(struct hid_device *hdev,
if (!data)
return 1;

if (size > 64) {
hid_warn(hdev, "invalid size value (%d) for picolcd raw event\n",
size);
return 0;
}

if (report->id == REPORT_KEY_STATE) {
if (data->input_keys)
ret = picolcd_raw_keypad(data, report, raw_data+1, size-1);
Expand Down

0 comments on commit e78c127

Please sign in to comment.