Skip to content

Commit

Permalink
[PATCH] hid-core: Zero-pad truncated reports
Browse files Browse the repository at this point in the history
When it detects a truncated report, hid-core emits a warning and then
processes the report as usual.  This is good because it allows buggy
devices to still get data thru to userspace.  However, the missing bytes of
the report should be cleared before processing, otherwise userspace will be
handed partially-uninitialized data.

This fixes Debian tracker bug #330487.

Signed-off-by: Adam Kropelin <akropel1@rochester.rr.com>
Cc: Vojtech Pavlik <vojtech@suse.cz>
Acked-by: Dmitry Torokhov <dtor_core@ameritech.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Adam Kropelin authored and Linus Torvalds committed Dec 14, 2005
1 parent fb79ffa commit cd61045
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/input/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,10 @@ static int hid_input_report(int type, struct urb *urb, int interrupt, struct pt_

size = ((report->size - 1) >> 3) + 1;

if (len < size)
if (len < size) {
dbg("report %d is too short, (%d < %d)", report->id, len, size);
memset(data + len, 0, size - len);
}

if (hid->claimed & HID_CLAIMED_HIDDEV)
hiddev_report_event(hid, report);
Expand Down

0 comments on commit cd61045

Please sign in to comment.