Fix error: array subscript 2 is above array bounds of 'uint8_t[2]'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
50f84f2632
commit
366e2d5f64
10 changed files with 62 additions and 55 deletions
|
@ -866,6 +866,7 @@ static int16_t usbclass_mkcfgdesc(FAR uint8_t *buf,
|
|||
|
||||
static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
||||
{
|
||||
FAR uint8_t *data = (FAR uint8_t *)(strdesc + 1);
|
||||
FAR const char *str;
|
||||
int len;
|
||||
int ndata;
|
||||
|
@ -878,10 +879,10 @@ static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
|||
{
|
||||
/* Descriptor 0 is the language id */
|
||||
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
strdesc->data[0] = LSBYTE(USBADB_STR_LANGUAGE);
|
||||
strdesc->data[1] = MSBYTE(USBADB_STR_LANGUAGE);
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
data[0] = LSBYTE(USBADB_STR_LANGUAGE);
|
||||
data[1] = MSBYTE(USBADB_STR_LANGUAGE);
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -928,8 +929,8 @@ static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
|||
|
||||
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
||||
{
|
||||
strdesc->data[ndata] = str[i];
|
||||
strdesc->data[ndata + 1] = 0;
|
||||
data[ndata] = str[i];
|
||||
data[ndata + 1] = 0;
|
||||
}
|
||||
|
||||
strdesc->len = ndata + 2;
|
||||
|
|
|
@ -115,12 +115,12 @@ static const struct usb_qualdesc_s g_qualdesc =
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int cdcacm_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
||||
int cdcacm_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
||||
{
|
||||
#if !defined(CONFIG_CDCACM_COMPOSITE) || defined(CONFIG_CDCACM_NOTIFSTR) || \
|
||||
defined(CONFIG_CDCACM_DATAIFSTR)
|
||||
|
||||
const char *str;
|
||||
FAR uint8_t *data = (FAR uint8_t *)(strdesc + 1);
|
||||
FAR const char *str;
|
||||
int len;
|
||||
int ndata;
|
||||
int i;
|
||||
|
@ -132,10 +132,10 @@ int cdcacm_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||
{
|
||||
/* Descriptor 0 is the language id */
|
||||
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
strdesc->data[0] = LSBYTE(CDCACM_STR_LANGUAGE);
|
||||
strdesc->data[1] = MSBYTE(CDCACM_STR_LANGUAGE);
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
data[0] = LSBYTE(CDCACM_STR_LANGUAGE);
|
||||
data[1] = MSBYTE(CDCACM_STR_LANGUAGE);
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -188,8 +188,8 @@ int cdcacm_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||
|
||||
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
||||
{
|
||||
strdesc->data[ndata] = str[i];
|
||||
strdesc->data[ndata + 1] = 0;
|
||||
data[ndata] = str[i];
|
||||
data[ndata + 1] = 0;
|
||||
}
|
||||
|
||||
strdesc->len = ndata + 2;
|
||||
|
|
|
@ -1365,7 +1365,8 @@ static int cdcecm_setinterface(FAR struct cdcecm_driver_s *self,
|
|||
|
||||
static int cdcecm_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
||||
{
|
||||
const char *str;
|
||||
FAR uint8_t *data = (FAR uint8_t *)(strdesc + 1);
|
||||
FAR const char *str;
|
||||
int len;
|
||||
int ndata;
|
||||
int i;
|
||||
|
@ -1377,10 +1378,10 @@ static int cdcecm_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
|||
{
|
||||
/* Descriptor 0 is the language id */
|
||||
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
strdesc->data[0] = LSBYTE(CDCECM_STR_LANGUAGE);
|
||||
strdesc->data[1] = MSBYTE(CDCECM_STR_LANGUAGE);
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
data[0] = LSBYTE(CDCECM_STR_LANGUAGE);
|
||||
data[1] = MSBYTE(CDCECM_STR_LANGUAGE);
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -1426,8 +1427,8 @@ static int cdcecm_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
|||
|
||||
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
||||
{
|
||||
strdesc->data[ndata] = str[i];
|
||||
strdesc->data[ndata + 1] = 0;
|
||||
data[ndata] = str[i];
|
||||
data[ndata + 1] = 0;
|
||||
}
|
||||
|
||||
strdesc->len = ndata + 2;
|
||||
|
|
|
@ -601,7 +601,7 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver,
|
|||
|
||||
buf->len = 18;
|
||||
buf->type = USB_DESC_TYPE_STRING;
|
||||
memcpy(buf->data, msft_response, 16);
|
||||
memcpy(buf + 1, msft_response, 16);
|
||||
ret = buf->len;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -118,9 +118,10 @@ static const struct usb_qualdesc_s g_qualdesc =
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int composite_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
||||
int composite_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
||||
{
|
||||
const char *str;
|
||||
FAR uint8_t *data = (FAR uint8_t *)(strdesc + 1);
|
||||
FAR const char *str;
|
||||
int len;
|
||||
int ndata;
|
||||
int i;
|
||||
|
@ -131,10 +132,10 @@ int composite_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||
{
|
||||
/* Descriptor 0 is the language id */
|
||||
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
strdesc->data[0] = LSBYTE(COMPOSITE_STR_LANGUAGE);
|
||||
strdesc->data[1] = MSBYTE(COMPOSITE_STR_LANGUAGE);
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
data[0] = LSBYTE(COMPOSITE_STR_LANGUAGE);
|
||||
data[1] = MSBYTE(COMPOSITE_STR_LANGUAGE);
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -169,8 +170,8 @@ int composite_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||
len = strlen(str);
|
||||
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
||||
{
|
||||
strdesc->data[ndata] = str[i];
|
||||
strdesc->data[ndata + 1] = 0;
|
||||
data[ndata] = str[i];
|
||||
data[ndata + 1] = 0;
|
||||
}
|
||||
|
||||
strdesc->len = ndata + 2;
|
||||
|
|
|
@ -271,7 +271,7 @@ static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
strdesc->len = 2 + convert_to_utf16(strdesc->data, str);
|
||||
strdesc->len = 2 + convert_to_utf16((FAR uint8_t *)(strdesc + 1), str);
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
return strdesc->len;
|
||||
}
|
||||
|
|
|
@ -828,9 +828,10 @@ static void usbclass_freereq(FAR struct usbdev_ep_s *ep,
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
||||
static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
||||
{
|
||||
const char *str;
|
||||
FAR uint8_t *data = (FAR uint8_t *)(strdesc + 1);
|
||||
FAR const char *str;
|
||||
int len;
|
||||
int ndata;
|
||||
int i;
|
||||
|
@ -841,10 +842,10 @@ static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||
{
|
||||
/* Descriptor 0 is the language id */
|
||||
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
strdesc->data[0] = LSBYTE(PL2303_STR_LANGUAGE);
|
||||
strdesc->data[1] = MSBYTE(PL2303_STR_LANGUAGE);
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
data[0] = LSBYTE(PL2303_STR_LANGUAGE);
|
||||
data[1] = MSBYTE(PL2303_STR_LANGUAGE);
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -884,8 +885,8 @@ static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||
|
||||
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
||||
{
|
||||
strdesc->data[ndata] = str[i];
|
||||
strdesc->data[ndata + 1] = 0;
|
||||
data[ndata] = str[i];
|
||||
data[ndata + 1] = 0;
|
||||
}
|
||||
|
||||
strdesc->len = ndata + 2;
|
||||
|
|
|
@ -1897,6 +1897,7 @@ static FAR struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep,
|
|||
|
||||
static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
||||
{
|
||||
FAR uint8_t *data = (FAR uint8_t *)(strdesc + 1);
|
||||
FAR const char *str;
|
||||
int len;
|
||||
int ndata;
|
||||
|
@ -1909,10 +1910,10 @@ static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
|||
{
|
||||
/* Descriptor 0 is the language id */
|
||||
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
strdesc->data[0] = LSBYTE(RNDIS_STR_LANGUAGE);
|
||||
strdesc->data[1] = MSBYTE(RNDIS_STR_LANGUAGE);
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
data[0] = LSBYTE(RNDIS_STR_LANGUAGE);
|
||||
data[1] = MSBYTE(RNDIS_STR_LANGUAGE);
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -1949,8 +1950,8 @@ static int usbclass_mkstrdesc(uint8_t id, FAR struct usb_strdesc_s *strdesc)
|
|||
|
||||
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
||||
{
|
||||
strdesc->data[ndata] = str[i];
|
||||
strdesc->data[ndata + 1] = 0;
|
||||
data[ndata] = str[i];
|
||||
data[ndata + 1] = 0;
|
||||
}
|
||||
|
||||
strdesc->len = ndata + 2;
|
||||
|
|
|
@ -128,9 +128,10 @@ const char g_mscserialstr[] = CONFIG_USBMSC_SERIALSTR;
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int usbmsc_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
||||
int usbmsc_mkstrdesc(uint8_t id, struct FAR usb_strdesc_s *strdesc)
|
||||
{
|
||||
const char *str;
|
||||
FAR uint8_t *data = (FAR uint8_t *)(strdesc + 1);
|
||||
FAR const char *str;
|
||||
int len;
|
||||
int ndata;
|
||||
int i;
|
||||
|
@ -142,10 +143,10 @@ int usbmsc_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||
{
|
||||
/* Descriptor 0 is the language id */
|
||||
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
strdesc->data[0] = LSBYTE(USBMSC_STR_LANGUAGE);
|
||||
strdesc->data[1] = MSBYTE(USBMSC_STR_LANGUAGE);
|
||||
strdesc->len = 4;
|
||||
strdesc->type = USB_DESC_TYPE_STRING;
|
||||
data[0] = LSBYTE(USBMSC_STR_LANGUAGE);
|
||||
data[1] = MSBYTE(USBMSC_STR_LANGUAGE);
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -188,8 +189,8 @@ int usbmsc_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||
|
||||
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
||||
{
|
||||
strdesc->data[ndata] = str[i];
|
||||
strdesc->data[ndata + 1] = 0;
|
||||
data[ndata] = str[i];
|
||||
data[ndata + 1] = 0;
|
||||
}
|
||||
|
||||
strdesc->len = ndata + 2;
|
||||
|
|
|
@ -336,7 +336,8 @@ struct usb_strdesc_s
|
|||
{
|
||||
uint8_t len; /* Descriptor length */
|
||||
uint8_t type; /* Descriptor type */
|
||||
uint8_t data[2];
|
||||
|
||||
/* uint8_t data[]; */
|
||||
};
|
||||
|
||||
/* Interface descriptor */
|
||||
|
|
Loading…
Reference in a new issue