mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] usb.c: warning on USB_MAXINTERFACES overflow
@ 2011-09-12 10:25 Antony Pavlov
  2011-09-13  7:32 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Antony Pavlov @ 2011-09-12 10:25 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 drivers/usb/core/usb.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index b01a797..5dc8afe 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -207,6 +207,16 @@ static int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int c
 			     &buffer[index])->bInterfaceNumber != curr_if_num) {
 				/* this is a new interface, copy new desc */
 				ifno = dev->config.no_of_if;
+				/* if ifno > USB_MAXINTERFACES, then
+				 * next memcpy() will corrupt dev->config
+				 */
+				if (ifno > USB_MAXINTERFACES) {
+					printf("ifno = %d > "
+						"USB_MAXINTERFACES = %d !\n",
+						ifno,
+						USB_MAXINTERFACES);
+					break;
+				}
 				dev->config.no_of_if++;
 				memcpy(&dev->config.if_desc[ifno],
 					&buffer[index], buffer[index]);
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb.c: warning on USB_MAXINTERFACES overflow
  2011-09-12 10:25 [PATCH] usb.c: warning on USB_MAXINTERFACES overflow Antony Pavlov
@ 2011-09-13  7:32 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2011-09-13  7:32 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Mon, Sep 12, 2011 at 02:25:46PM +0400, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>

Applied to master.

Sascha

> ---
>  drivers/usb/core/usb.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
> index b01a797..5dc8afe 100644
> --- a/drivers/usb/core/usb.c
> +++ b/drivers/usb/core/usb.c
> @@ -207,6 +207,16 @@ static int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int c
>  			     &buffer[index])->bInterfaceNumber != curr_if_num) {
>  				/* this is a new interface, copy new desc */
>  				ifno = dev->config.no_of_if;
> +				/* if ifno > USB_MAXINTERFACES, then
> +				 * next memcpy() will corrupt dev->config
> +				 */
> +				if (ifno > USB_MAXINTERFACES) {
> +					printf("ifno = %d > "
> +						"USB_MAXINTERFACES = %d !\n",
> +						ifno,
> +						USB_MAXINTERFACES);
> +					break;
> +				}
>  				dev->config.no_of_if++;
>  				memcpy(&dev->config.if_desc[ifno],
>  					&buffer[index], buffer[index]);
> -- 
> 1.7.5.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-13  7:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-12 10:25 [PATCH] usb.c: warning on USB_MAXINTERFACES overflow Antony Pavlov
2011-09-13  7:32 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox