USB: gadget: Read buffer overflow
authorRoel Kluin <roel.kluin@gmail.com>
Thu, 6 Aug 2009 23:09:51 +0000 (16:09 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 23 Sep 2009 13:46:32 +0000 (06:46 -0700)
Check whether index is within bounds before testing the element.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/gadget/composite.c

index 59e85234fa0ad614cfb9a181d27007653c250a51..d05397ec8a183ebb4467b10f55fe9b67e1cce189 100644 (file)
@@ -602,7 +602,7 @@ static int get_string(struct usb_composite_dev *cdev,
                        }
                }
 
-               for (len = 0; s->wData[len] && len <= 126; len++)
+               for (len = 0; len <= 126 && s->wData[len]; len++)
                        continue;
                if (!len)
                        return -EINVAL;