USB device. All class drivers. There needs to be a check to make sure that the size of a returned string does not exceed the size of an allocated request buffer
This commit is contained in:
parent
a4ccbd8c4a
commit
6ef7977b65
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbdev/cdcacm.h
|
* drivers/usbdev/cdcacm.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011-2012, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -119,6 +119,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define CDCACM_MXDESCLEN (64)
|
#define CDCACM_MXDESCLEN (64)
|
||||||
|
#defien CDCACM_MAXSTRLEN (CDCACM_MXDESCLEN-2)
|
||||||
|
|
||||||
/* Device descriptor values */
|
/* Device descriptor values */
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbdev/cdcacm_desc.c
|
* drivers/usbdev/cdcacm_desc.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011-2012, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -472,6 +472,11 @@ int cdcacm_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
if (len > (CDCACM_MAXSTRLEN / 2))
|
||||||
|
{
|
||||||
|
len = (CDCACM_MAXSTRLEN / 2);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
||||||
{
|
{
|
||||||
strdesc->data[ndata] = str[i];
|
strdesc->data[ndata] = str[i];
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbdev/pl2303.c
|
* drivers/usbdev/pl2303.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2013, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* This logic emulates the Prolific PL2303 serial/USB converter
|
* This logic emulates the Prolific PL2303 serial/USB converter
|
||||||
@ -194,6 +194,7 @@
|
|||||||
/* Buffer big enough for any of our descriptors */
|
/* Buffer big enough for any of our descriptors */
|
||||||
|
|
||||||
#define PL2303_MXDESCLEN (64)
|
#define PL2303_MXDESCLEN (64)
|
||||||
|
#defien PL2303_MAXSTRLEN (PL2303_MXDESCLEN-2)
|
||||||
|
|
||||||
/* Vender specific control requests *******************************************/
|
/* Vender specific control requests *******************************************/
|
||||||
|
|
||||||
@ -871,6 +872,11 @@ static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
if (len > (PL2303_MAXSTRLEN / 2))
|
||||||
|
{
|
||||||
|
len = (PL2303_MAXSTRLEN / 2);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
||||||
{
|
{
|
||||||
strdesc->data[ndata] = str[i];
|
strdesc->data[ndata] = str[i];
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbdev/usbmsc.h
|
* drivers/usbdev/usbmsc.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2013, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Mass storage class device. Bulk-only with SCSI subclass.
|
* Mass storage class device. Bulk-only with SCSI subclass.
|
||||||
@ -269,6 +269,7 @@
|
|||||||
/* Big enough to hold our biggest descriptor */
|
/* Big enough to hold our biggest descriptor */
|
||||||
|
|
||||||
#define USBMSC_MXDESCLEN (64)
|
#define USBMSC_MXDESCLEN (64)
|
||||||
|
#defien USBMSC_MAXSTRLEN (USBMSC_MXDESCLEN-2)
|
||||||
|
|
||||||
/* String language */
|
/* String language */
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/usbdev/usbmsc_desc.c
|
* drivers/usbdev/usbmsc_desc.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011-2012, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -287,6 +287,11 @@ int usbmsc_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
if (len > (USBMSC_MAXSTRLEN / 2))
|
||||||
|
{
|
||||||
|
len = (USBMSC_MAXSTRLEN / 2);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
for (i = 0, ndata = 0; i < len; i++, ndata += 2)
|
||||||
{
|
{
|
||||||
strdesc->data[ndata] = str[i];
|
strdesc->data[ndata] = str[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user