Hi, All:
I noticed (from reading usbmon traces) that we request string descriptors
with size 255, which is odd (please pardon the pub), because a string
descriptor consists of 16-bit characters and 2-byte header. Does anyone
know if this length has any meaning or is it just a thinko?
-- Pete
diff -urp -X dontdiff linux-2.6.12-rc6/drivers/usb/core/message.c
linux-2.6.12-rc6-lem/drivers/usb/core/message.c
--- linux-2.6.12-rc6/drivers/usb/core/message.c 2005-06-06 13:44:37.000000000
-0700
+++ linux-2.6.12-rc6-lem/drivers/usb/core/message.c 2005-06-07
16:40:02.000000000 -0700
@@ -24,6 +24,12 @@
#include "hcd.h" /* for usbcore internals */
#include "usb.h"
+/*
+ * Since this is 256, we do not need to check for overflow the one-byte
+ * size supplied by device (see usb_string_sub).
+ */
+#define USB_DT_STRING_SIZE 256
+
static void usb_api_blocking_completion(struct urb *urb, struct pt_regs *regs)
{
complete((struct completion *)urb->context);
@@ -660,7 +666,7 @@ static int usb_string_sub(struct usb_dev
/* Try to read the string descriptor by asking for the maximum
* possible number of bytes */
- rc = usb_get_string(dev, langid, index, buf, 255);
+ rc = usb_get_string(dev, langid, index, buf, USB_DT_STRING_SIZE);
/* If that failed try to read the descriptor length, then
* ask for just that many bytes */
@@ -722,7 +728,7 @@ int usb_string(struct usb_device *dev, i
if (size <= 0 || !buf || !index)
return -EINVAL;
buf[0] = 0;
- tbuf = kmalloc(256, GFP_KERNEL);
+ tbuf = kmalloc(USB_DT_STRING_SIZE, GFP_KERNEL);
if (!tbuf)
return -ENOMEM;
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel