mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
usb: remove null termination on serial number string
The serial number string descriptor was incorrectly null terminated. The standard clearly states that there should not be a null terminator. Use new #defines to ensure that our strings are sized properly.
This commit is contained in:
parent
b905607dc7
commit
19367730c0
@ -51,7 +51,7 @@ static const uint8_t usb_product_id[28] = {
|
||||
'l', 0,
|
||||
};
|
||||
|
||||
static uint8_t usb_serial_number[2 + 25*2 + 3*2] = {
|
||||
static uint8_t usb_serial_number[2 + PIOS_SYS_SERIAL_NUM_ASCII_LEN*2 + 3*2] = {
|
||||
sizeof(usb_serial_number),
|
||||
USB_DESC_TYPE_STRING,
|
||||
};
|
||||
@ -83,7 +83,7 @@ static const uint8_t usb_vendor_id[28] = {
|
||||
int32_t PIOS_USB_BOARD_DATA_Init(void)
|
||||
{
|
||||
/* Load device serial number into serial number string */
|
||||
uint8_t sn[25+3];
|
||||
uint8_t sn[PIOS_SYS_SERIAL_NUM_ASCII_LEN+strlen(PIOS_USB_BOARD_SN_SUFFIX)+1];
|
||||
PIOS_SYS_SerialNumberGet((char *)sn);
|
||||
|
||||
/* Add the appropriate suffix ("+BL" or "+FW") depending on what we're running */
|
||||
|
@ -51,7 +51,7 @@ static const uint8_t usb_product_id[28] = {
|
||||
'l', 0,
|
||||
};
|
||||
|
||||
static uint8_t usb_serial_number[2 + 25*2 + 3*2] = {
|
||||
static uint8_t usb_serial_number[2 + PIOS_SYS_SERIAL_NUM_ASCII_LEN*2 + 3*2] = {
|
||||
sizeof(usb_serial_number),
|
||||
USB_DESC_TYPE_STRING,
|
||||
};
|
||||
@ -83,7 +83,7 @@ static const uint8_t usb_vendor_id[28] = {
|
||||
int32_t PIOS_USB_BOARD_DATA_Init(void)
|
||||
{
|
||||
/* Load device serial number into serial number string */
|
||||
uint8_t sn[25+3];
|
||||
uint8_t sn[PIOS_SYS_SERIAL_NUM_ASCII_LEN+strlen(PIOS_USB_BOARD_SN_SUFFIX)+1];
|
||||
PIOS_SYS_SerialNumberGet((char *)sn);
|
||||
|
||||
/* Add the appropriate suffix ("+BL" or "+FW") depending on what we're running */
|
||||
|
Loading…
x
Reference in New Issue
Block a user