diff options
author | Martin Koegler <mkoegler@auto.tuwien.ac.at> | 2010-04-19 19:22:46 -0300 |
---|---|---|
committer | Daniel Drake <dan@reactivated.net> | 2010-04-19 19:22:46 -0300 |
commit | 9bea500b5747bdeba7c8251d45608558e71a1db5 (patch) | |
tree | 1ebbfe689dafc58fc2fe52fb9bff5a2bff93a524 | |
parent | 02df59a309e813c50b8230de99e69fb4e1814279 (diff) | |
download | libusb-9bea500b5747bdeba7c8251d45608558e71a1db5.tar.gz |
Linux: correct config descriptor endianness fix
The seek_to_next_config codepath deals with both sysfs and usbfs;
make sure we only convert values in the usbfs path.
-rw-r--r-- | libusb/os/linux_usbfs.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 2a881a1..bdd7e1d 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -381,7 +381,8 @@ static int sysfs_get_active_config(struct libusb_device *dev, int *config) /* takes a usbfs/descriptors fd seeked to the start of a configuration, and * seeks to the next one. */ -static int seek_to_next_config(struct libusb_context *ctx, int fd) +static int seek_to_next_config(struct libusb_context *ctx, int fd, + int host_endian) { struct libusb_config_descriptor config; unsigned char tmp[6]; @@ -399,7 +400,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, 0); + usbi_parse_descriptor(tmp, "bbwbb", &config, host_endian); off = lseek(fd, config.wTotalLength - sizeof(tmp), SEEK_CUR); if (off < 0) { usbi_err(ctx, "seek failed ret=%d errno=%d", off, errno); @@ -476,7 +477,7 @@ static int sysfs_get_active_config_descriptor(struct libusb_device *dev, if (off < 0) return LIBUSB_ERROR_IO; - r = seek_to_next_config(DEVICE_CTX(dev), fd); + r = seek_to_next_config(DEVICE_CTX(dev), fd, 1); if (r < 0) return r; } @@ -531,7 +532,7 @@ static int get_config_descriptor(struct libusb_context *ctx, int fd, /* might need to skip some configuration descriptors to reach the * requested configuration */ while (config_index > 0) { - r = seek_to_next_config(ctx, fd); + r = seek_to_next_config(ctx, fd, 0); if (r < 0) return r; config_index--; |