Skip to content

Commit

Permalink
HID: hid-cypress: validate length of report
Browse files Browse the repository at this point in the history
Make sure we have enough of a report structure to validate before
looking at it.

Reported-by: Benoit Camredon <benoit.camredon@airbus.com>
Tested-by: Benoit Camredon <benoit.camredon@airbus.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Greg Kroah-Hartman authored and Jiri Kosina committed Jan 6, 2017
1 parent 08f9572 commit 1ebb711
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/hid/hid-cypress.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ static __u8 *cp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
if (!(quirks & CP_RDESC_SWAPPED_MIN_MAX))
return rdesc;

if (*rsize < 4)
return rdesc;

for (i = 0; i < *rsize - 4; i++)
if (rdesc[i] == 0x29 && rdesc[i + 2] == 0x19) {
rdesc[i] = 0x19;
Expand Down

0 comments on commit 1ebb711

Please sign in to comment.