Check index bounds on usb string descriptor request.
This commit is contained in:
parent
cd88855d13
commit
7434d50fda
@ -98,6 +98,11 @@ static int usb_standard_get_descriptor(struct usb_setup_data *req,
|
||||
if (!_usbd_device.strings)
|
||||
return 0; /* Device doesn't support strings. */
|
||||
|
||||
/* Check that string index is in range */
|
||||
for(i = 0; i <= (req->wValue & 0xff); i++)
|
||||
if(_usbd_device.strings[i] == NULL)
|
||||
return 0;
|
||||
|
||||
sd->bLength = strlen(_usbd_device.strings[req->wValue & 0xff])
|
||||
* 2 + 2;
|
||||
sd->bDescriptorType = USB_DT_STRING;
|
||||
|
Loading…
x
Reference in New Issue
Block a user