usb/80773: "usbd_get_string()" could have taken a length parameter

Hans Petter Selasky hselasky at c2i.net
Sat Feb 25 01:17:01 PST 2006


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


More information about the freebsd-usb mailing list