Date: Sat, 25 Feb 2006 10:17:11 +0100 From: Hans Petter Selasky <hselasky@c2i.net> To: Ian Dowse <iedowse@freebsd.org> Cc: freebsd-usb@freebsd.org Subject: Re: usb/80773: "usbd_get_string()" could have taken a length parameter Message-ID: <200602251017.12146.hselasky@c2i.net> In-Reply-To: <200602250411.k1P4BQ13052649@freefall.freebsd.org> References: <200602250411.k1P4BQ13052649@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 25 February 2006 05:11, Ian Dowse wrote: > Synopsis: "usbd_get_string()" could have taken a length parameter > > State-Changed-From-To: open->feedback > State-Changed-By: iedowse > State-Changed-When: Sat Feb 25 04:10:27 UTC 2006 > State-Changed-Why: > > Can you provide a patch against -CURRENT to address this? > > http://www.freebsd.org/cgi/query-pr.cgi?pr=80773 #define usbd_get_string(udev, si, ptr) usbreq_get_string_any(udev, si, ptr, USB_MAX_STRING_LEN) /* Use "usbreq_get_string_any()" instead of * "usbreq_get_string_desc()", when the language id is not known. The * maximum length of the string, "len", includes the terminating zero. * "usbreq_get_string_any()" will always write a terminating zero to "buf", * also on error. */ usbd_status usbreq_get_string_any(struct usbd_device *udev, int si, char *buf, int len) { ... } I've already fixed this in my new USB driver. It is not critical, but it can be a pitfall for programmers, writing too long strings into too short fields. --HPS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200602251017.12146.hselasky>