Skip to main content
marcomarco9119
Associate
November 21, 2013
Question

Bug in USB library v4.0.0 usb_prop.c

  • November 21, 2013
  • 0 replies
  • 670 views
Posted on November 21, 2013 at 01:28

I've come across an issue in usb_prop.c in the STM32 USB library examples. The _GetStringDescriptor function checks for the index of the Descriptor string, but allows an index of up to 4. There are actually only 4 strings in the Descriptor array, so index 4 is out of bounds and results in a hard fault. We've come across some applications that for whatever reason attempt to open all connected HID devices and grab a 5th string. The fix is to change the function as follows:

uint8_t *CustomHID_GetStringDescriptor(uint16_t Length)
{
uint8_t wValue0 = pInformation->USBwValue0;
// This is modified from ST's library. There are only 4 strings
if
(wValue0 >= 4)
{
return
NULL;
}
else
{
return
Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]);
}
}

    This topic has been closed for replies.