Skip to contentSkip to conversation

usb: Expand buffer size in usb_find_and_bind_driver()

PATCH In review Marek Vasut 2 participants 2 messages Nov 26, 2022 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: Expand buffer size in usb_find_and_bind_driver()

The "generic_bus_%x_dev_%x" string which is printed into this buffer can be up to 34 characters long ("generic_bus_12345678_dev_12345678"). The buffer would be clipped by snprintf() if both %x were at maximum range. Make sure the buffer is long enough to cover such possibility.

---
Cc: Sean Anderson <[email protected]>
Cc: Simon Glass <[email protected]>

---
 drivers/usb/host/usb-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/usb-uclass.c +1 -1
index 27e2fc6fcd3..060f3441df0 100644
@@ -557,7 +557,7 @@ static int usb_find_and_bind_driver(struct udevice *parent,
 	struct usb_driver_entry *start, *entry;
 	int n_ents;
 	int ret;
-	char name[30], *str;
+	char name[34], *str;
 	ofnode node = usb_get_ofnode(parent, port);
 
 	*devp = NULL;
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Marek Vasut

The "generic_bus_%x_dev_%x" string which is printed into this buffer can be up to 34 characters long ("generic_bus_12345678_dev_12345678"). The buffer would be clipped by snprintf() if both %x were at maximum range. Make sure the buffer is long enough to cover such possibility.

Quoted 8 lines

---
Cc: Sean Anderson <[email protected]>
Cc: Simon Glass <[email protected]>

---
 drivers/usb/host/usb-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)