Linux: Fix endianness handling of usbfs config descriptors (#27)
authorMartin Koegler <mkoegler@auto.tuwien.ac.at>
Mon, 5 Apr 2010 15:11:32 +0000 (17:11 +0200)
committerDaniel Drake <dan@reactivated.net>
Mon, 5 Apr 2010 16:08:20 +0000 (10:08 -0600)
driver/usb/core/devio.c function usbdev_read translate the follwing files
to CPU endianess:

le16_to_cpus(&temp_desc.bcdUSB);
le16_to_cpus(&temp_desc.idVendor);
le16_to_cpus(&temp_desc.idProduct);
le16_to_cpus(&temp_desc.bcdDevice);

All other data is passed without any change.

libusb/os/linux_usbfs.c calls usbi_parse_descriptor with host_endian=1
for config descriptors. According to the kernel code, they must be
processed with host_endian=0, as they are not translated by the kernel.

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
AUTHORS
libusb/os/linux_usbfs.c

diff --git a/AUTHORS b/AUTHORS
index 495a72e..dc0e053 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -12,6 +12,7 @@ David Moore
 Felipe Balbi
 Hans Ulrich Niedermann
 Ludovic Rousseau
+Martin Koegler
 Mikhail Gusarov
 Rob Walker
 Toby Peterson
index ffa4088..2a881a1 100644 (file)
@@ -399,7 +399,7 @@ static int seek_to_next_config(struct libusb_context *ctx, int fd)
        }
 
        /* seek forward to end of config */
-       usbi_parse_descriptor(tmp, "bbwbb", &config, 1);
+       usbi_parse_descriptor(tmp, "bbwbb", &config, 0);
        off = lseek(fd, config.wTotalLength - sizeof(tmp), SEEK_CUR);
        if (off < 0) {
                usbi_err(ctx, "seek failed ret=%d errno=%d", off, errno);
@@ -606,7 +606,7 @@ static int cache_active_config(struct libusb_device *dev, int fd,
                return r;
        }
 
-       usbi_parse_descriptor(tmp, "bbw", &config, 1);
+       usbi_parse_descriptor(tmp, "bbw", &config, 0);
        buf = malloc(config.wTotalLength);
        if (!buf)
                return LIBUSB_ERROR_NO_MEM;