# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.678   -> 1.679  
#       drivers/usb/core/message.c      1.9     -> 1.10   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/10/02      [EMAIL PROTECTED]      1.679
# [PATCH] USB: string query fix
# 
# Query for stringlen before reading a string in usb.c
# --------------------------------------------
#
diff -Nru a/drivers/usb/core/message.c b/drivers/usb/core/message.c
--- a/drivers/usb/core/message.c        Wed Oct  2 22:40:26 2002
+++ b/drivers/usb/core/message.c        Wed Oct  2 22:40:26 2002
@@ -924,7 +924,7 @@
 int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
 {
        unsigned char *tbuf;
-       int err;
+       int err, len;
        unsigned int u, idx;
 
        if (size <= 0 || !buf || !index)
@@ -954,10 +954,15 @@
        }
 
        /*
-        * Just ask for a maximum length string and then take the length
-        * that was returned.
+        * ask for the length of the string 
         */
-       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)
                goto errout;
 


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to