Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bbccd318 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "USB: core: fix out-of-bounds access bug in usb_get_bos_descriptor()"

parents cba8a7d8 54cfa00f
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -829,10 +829,12 @@ int usb_get_bos_descriptor(struct usb_device *dev)
	for (i = 0; i < num; i++) {
		buffer += length;
		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;
		}
		length = cap->bLength;
		total_len -= length;

		if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) {