Endian bug in lsusb
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
usbutils (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: usbutils
There's an endian bug in the lsusb version used in Ubuntu. At the top of the lsusb.c file you can read:
#if (__BYTE_ORDER == __LITTLE_ENDIAN)
#define le16_to_cpu(x) (x)
#elif (__BYTE_ORDER == __BIG_ENDIAN)
#define le16_to_cpu(x) bswap_16(x)
#else
#error missing BYTE_ORDER
#endif
Which is then used whenever reading some 16-bit fields off descriptors.
This is incorrect. All the descriptor data structures are parsed by libusb using usb_parse_
already converts the endian of >8-bit fields. Hence, all pre-parsed descriptors coming into libusb should
-not- be swapped again.
Note that the "upstream" lsusb is even more funny, it does:
#define le16_to_cpu(x) libusb_
IE. It swaps -twice- which is stupid ... but probably works :-)
The right thing to do is to rip all of that out including the two call sites of le16_to_cpu()
as it's all in native endian already when coming out of libusb.
ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: usbutils 0.87-4
Uname: Linux 2.6.37 ppc64
Architecture: powerpc
Date: Tue Mar 22 17:35:44 2011
ProcEnviron:
SHELL=/bin/bash
PATH=(custom, user)
LANG=en_AU.utf8
LANGUAGE=en_AU:en
SourcePackage: usbutils