Skip to content

Commit 9870a47

Browse files
authored
F4: USBD_StrDesc[] size fix
- bug: memory overflow for size values less than 62, in function USBD_GetString(). The array in question (USBD_StrDesc) is followed in memory by 2 fill bytes for the current compile order. Arduino 1.8.6 compiles the files in different order, so that the USB will not working anymore. The longest string is 32 bytes long (plus ending zero), and 2 more bytes will be added at the beginning (https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/master/STM32F4/cores/maple/libmaple/usbF4/STM32_USB_Device_Library/Core/src/usbd_req.c#L818-L834). The last 2 bytes are fill bytes (align 4).
1 parent d4b3cd1 commit 9870a47

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

STM32F4/cores/maple/libmaple/usbF4/VCP/usbd_conf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
#define USBD_CFG_MAX_NUM 1
3434
#define USBD_ITF_MAX_NUM 1
35-
#define USB_MAX_STR_DESC_SIZ 50
35+
#define USB_MAX_STR_DESC_SIZ (64+4) // longest descriptor string length + 2
3636

3737
/** @defgroup USB_VCP_Class_Layer_Parameter
3838
* @{

0 commit comments

Comments
 (0)