|
@@ -960,10 +960,12 @@ int usb_get_bos_descriptor(struct usb_device *dev)
|
|
for (i = 0; i < num; i++) {
|
|
for (i = 0; i < num; i++) {
|
|
buffer += length;
|
|
buffer += length;
|
|
cap = (struct usb_dev_cap_header *)buffer;
|
|
cap = (struct usb_dev_cap_header *)buffer;
|
|
- length = cap->bLength;
|
|
|
|
|
|
|
|
- if (total_len < length)
|
|
|
|
|
|
+ if (total_len < sizeof(*cap) || total_len < cap->bLength) {
|
|
|
|
+ dev->bos->desc->bNumDeviceCaps = i;
|
|
break;
|
|
break;
|
|
|
|
+ }
|
|
|
|
+ length = cap->bLength;
|
|
total_len -= length;
|
|
total_len -= length;
|
|
|
|
|
|
if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {
|
|
if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {
|