You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My OnePlus 8 Pro provides different USB config descriptor dependent on its current situation.
I would expect that all the descriptor could be parsed but this seems not to be the case.
The problem itself is not hardware dependent.
I captured the different config descriptor provided by my phone and extract the parsing code to a stand alone project. So I could inspect the failure in a simple test.
How To Reproduce
Use one of the captured USB config descriptor.
Use the USBH_ParseCfgDesc function to parse the data.
For two of the three different descriptor all is fine, for the third one the function will never return.
returns the same pdesc pointer as has been provided. This is caused because pdesc->bLength == 0.
This is currently not really be caused by the provided config descriptor but how the descriptor is handled by your parsing code.
Regardless which situation results into a length of zero, the function should be hardened to not enter and endless loop.
This could be done simple by replacing the two calls to get next desc with code like this:
if (pdesc->bLength==0)
{
returnUSBH_NOT_SUPPORTED;
}
pdesc=USBH_GetNextDesc((uint8_t*)(void*)pdesc, &ptr);
But IMHO the real buggy behaviour is that the config descriptor is not parsed as given but there are some magic corrections
/* Make sure that the endpoint descriptor's bLength is equal to USB_ENDPOINT_DESC_SIZE for all other endpoints types */elseif (pdesc->bLength !=USB_ENDPOINT_DESC_SIZE)
{
pdesc->bLength=USB_ENDPOINT_DESC_SIZE;
}
This seems strange to me.
As you can see there are 4 endpoints (type 0x05) in the third descriptor:
two uses a length of 0x09 and two uses a length of 0x07.
Your code ignores the given length of 0x09 and set USB_ENDPOINT_DESC_SIZE (0x07U) as length.
This will corrupt the whole data handling as pdesc / ptr will not be increased by the 9 bytes but only by 7 and so the whole further data is not inspected at the correct byte places.
The text was updated successfully, but these errors were encountered:
I have similar problem with this part of the code. Connecting an android as midi usb to stm32 would result in endless loop in this part of the code. I posted my issue in stm32_mw_usb_host .
Describe the set-up
Describe the bug
My OnePlus 8 Pro provides different USB config descriptor dependent on its current situation.
I would expect that all the descriptor could be parsed but this seems not to be the case.
The problem itself is not hardware dependent.
I captured the different config descriptor provided by my phone and extract the parsing code to a stand alone project. So I could inspect the failure in a simple test.
How To Reproduce
Additional context
Here the three USB config descriptors:
The function does not return because the current implementation will lead to the situation that a call to
returns the same pdesc pointer as has been provided. This is caused because
pdesc->bLength == 0
.This is currently not really be caused by the provided config descriptor but how the descriptor is handled by your parsing code.
Regardless which situation results into a length of zero, the function should be hardened to not enter and endless loop.
This could be done simple by replacing the two calls to get next desc with code like this:
But IMHO the real buggy behaviour is that the config descriptor is not parsed as given but there are some magic corrections
This seems strange to me.
As you can see there are 4 endpoints (type 0x05) in the third descriptor:
two uses a length of 0x09 and two uses a length of 0x07.
Your code ignores the given length of 0x09 and set
USB_ENDPOINT_DESC_SIZE
(0x07U) as length.This will corrupt the whole data handling as pdesc / ptr will not be increased by the 9 bytes but only by 7 and so the whole further data is not inspected at the correct byte places.
The text was updated successfully, but these errors were encountered: