Skip to contentSkip to conversation

usb.c: warning on USB_MAXINTERFACES overflow

PATCH Applied Antony Pavlov 2 participants 2 messages Sep 12, 2011 – Sep 13, 2011 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb.c: warning on USB_MAXINTERFACES overflow

---
 drivers/usb/core/usb.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/usb/core/usb.c +10 -0
index b01a797..5dc8afe 100644
@@ -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]);
Signature · 7 lines
1.7.5.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 1 line · Antony Pavlov

Applied to master.

Sascha

Quoted 34 lines
---
 drivers/usb/core/usb.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/usb/core/usb.c +10 -0
index b01a797..5dc8afe 100644
@@ -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]);
Signature · 7 lines
1.7.5.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox