Commit 3737f5e6 authored by Jochen Karrer's avatar Jochen Karrer Committed by Greg Kroah-Hartman

[PATCH] USB: string query fix

Query for stringlen before reading a string in usb.c
parent 1b555543
...@@ -924,7 +924,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration) ...@@ -924,7 +924,7 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
int usb_string(struct usb_device *dev, int index, char *buf, size_t size) int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
{ {
unsigned char *tbuf; unsigned char *tbuf;
int err; int err, len;
unsigned int u, idx; unsigned int u, idx;
if (size <= 0 || !buf || !index) if (size <= 0 || !buf || !index)
...@@ -954,10 +954,15 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) ...@@ -954,10 +954,15 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
} }
/* /*
* Just ask for a maximum length string and then take the length * ask for the length of the string
* that was returned.
*/ */
err = usb_get_string(dev, dev->string_langid, index, tbuf, 255);
err = usb_get_string(dev, dev->string_langid, index, tbuf, 2);
if(err<2)
goto errout;
len=tbuf[0];
err = usb_get_string(dev, dev->string_langid, index, tbuf, len);
if (err < 0) if (err < 0)
goto errout; goto errout;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment