I will have to fix and resubmit this patch. I realized that the USB string descriptors (like the other USB descriptors) have a bLength field that is only one byte wide, so any descriptor is maximum 255 bytes (which after the bLength and bDescritorType fields leaves 253 bytes for the string. The string is in Unicode and I have only seen 2-byte UTF-16 implementations, which is also what libusb supports. So the resulting ascii string can be maximum 126 characters long + zero termination byte. Although for what I know UTF-8 could theoretically be possible, which would mean up to 253 characters.
Maybe rename it to MAX_DESC_STR_LEN? I think MAX_STR_LEN sounds too much like a more generic OS or library string limitation. Tormod >From http://en.wikipedia.org/wiki/USB USB 2.0 Engineering Change Notices "Unicode ECN: Released in February 2005. This ECN specifies that strings are encoded using UTF-16LE. USB 2.0 did specify that Unicode is to be used but it did not specify the encoding." On Wed, Aug 31, 2011 at 11:26 PM, Tormod Volden <[email protected]> wrote: > From: Tormod Volden <[email protected]> > > The way we retrieve these strings we just have to make sure the buffer > is big enough to not truncate the string. I do not know if the USB > protocol sets any limit to the string length. If not, a possible TODO > would be to add a warning if the returned string filled the buffer. _______________________________________________ devel mailing list [email protected] https://lists.openmoko.org/mailman/listinfo/devel
