Skip to content

Commit 3a034a7

Browse files
LekensteynJiri Kosina
authored andcommitted
HID: logitech-hidpp: add boundary check for name retrieval
The HID response has a limited size. Do not trust the value returned by hardware, check that it really fits in the message. Signed-off-by: Peter Wu <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 1430ee7 commit 3a034a7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/hid/hid-logitech-hidpp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ static char *hidpp_get_unifying_name(struct hidpp_device *hidpp_dev)
313313

314314
len = response.rap.params[1];
315315

316+
if (2 + len > sizeof(response.rap.params))
317+
return NULL;
318+
316319
name = kzalloc(len + 1, GFP_KERNEL);
317320
if (!name)
318321
return NULL;

0 commit comments

Comments
 (0)