summaryrefslogtreecommitdiff
path: root/sys/dev/usb/usb_subr.c
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2005-08-01 05:36:50 +0000
committerBrad Smith <brad@cvs.openbsd.org>2005-08-01 05:36:50 +0000
commit2e4c19f779ce48faaf5abcaa186def74956a6981 (patch)
tree2a7d441b21de326c5a27b994bce0b47dcb3dd0e7 /sys/dev/usb/usb_subr.c
parent0fd85d9caed3489931a1fa9c2b7520960293653d (diff)
Don't keep the devinfo string on the stack, instead use malloc/free.
This should cure some rare stack overflows. From augustss NetBSD ok dlg@ pascoe@
Diffstat (limited to 'sys/dev/usb/usb_subr.c')
-rw-r--r--sys/dev/usb/usb_subr.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index 7f8fecb669d..bcdfbed79a1 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_subr.c,v 1.37 2005/07/18 02:43:27 fgsch Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.38 2005/08/01 05:36:49 brad Exp $ */
/* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -77,6 +77,7 @@ extern int usbdebug;
#endif
Static usbd_status usbd_set_config(usbd_device_handle, int);
+Static void usbd_devinfo(usbd_device_handle, int, char *, size_t);
Static void usbd_devinfo_vp(usbd_device_handle, char *, char *, int);
Static char *usbd_get_string(usbd_device_handle, int, char *);
Static int usbd_getnewaddr(usbd_bus_handle bus);
@@ -312,7 +313,7 @@ usbd_printBCD(char *cp, size_t len, int bcd)
return (l);
}
-void
+Static void
usbd_devinfo(usbd_device_handle dev, int showclass, char *base, size_t len)
{
usb_device_descriptor_t *udd = &dev->ddesc;
@@ -344,6 +345,22 @@ usbd_devinfo(usbd_device_handle dev, int showclass, char *base, size_t len)
*cp = 0;
}
+char *
+usbd_devinfo_alloc(usbd_device_handle dev, int showclass)
+{
+ char *devinfop;
+
+ devinfop = malloc(DEVINFOSIZE, M_TEMP, M_WAITOK);
+ usbd_devinfo(dev, showclass, devinfop, DEVINFOSIZE);
+ return devinfop;
+}
+
+void
+usbd_devinfo_free(char *devinfop)
+{
+ free(devinfop, M_TEMP);
+}
+
/* Delay for a certain number of ms */
void
usb_delay_ms(usbd_bus_handle bus, u_int ms)