fix(core/usbh_core): Fix raw_config_desc heap out of bounds

This commit is contained in:
CCHhui 2024-09-16 22:35:46 +08:00 committed by sakumisu
parent 0371bb921c
commit 171b36e766

View File

@ -486,7 +486,7 @@ int usbh_enumerate(struct usbh_hubport *hport)
goto errout; goto errout;
} }
USB_LOG_INFO("The device has %d interfaces\r\n", ((struct usb_configuration_descriptor *)ep0_request_buffer[hport->bus->busid])->bNumInterfaces); USB_LOG_INFO("The device has %d interfaces\r\n", ((struct usb_configuration_descriptor *)ep0_request_buffer[hport->bus->busid])->bNumInterfaces);
hport->raw_config_desc = usb_osal_malloc(wTotalLength); hport->raw_config_desc = usb_osal_malloc(wTotalLength + 1);
if (hport->raw_config_desc == NULL) { if (hport->raw_config_desc == NULL) {
ret = -USB_ERR_NOMEM; ret = -USB_ERR_NOMEM;
USB_LOG_ERR("No memory to alloc for raw_config_desc\r\n"); USB_LOG_ERR("No memory to alloc for raw_config_desc\r\n");