linux: Properly deal with invalid config.wTotalLength in sysfs
authorHans de Goede <hdegoede@redhat.com>
Thu, 23 May 2013 11:25:08 +0000 (13:25 +0200)
committerHans de Goede <hdegoede@redhat.com>
Fri, 24 May 2013 11:58:37 +0000 (13:58 +0200)
commitaf06916bed2c7eb3b1a1a144348ebc7478097604
treef0f5fe2abc913e5005de4036d5014660dc7ed634
parentb241dd329cdad2779158e417e086b6a9bb9d6a2d
linux: Properly deal with invalid config.wTotalLength in sysfs

In usbfs wTotalLength can be trusted, in the sense that the kernel simple
has holes in the descriptors file when a device returns a smaller config
descriptor then advertised.

In sysfs this is not the case, sysfs descriptors only contain descriptors
actually returned by the device, with no holes. The kernel does validate
the bLength field of all the descriptors and removes any invalid ones.

So with sysfs we cannot rely on wTotalLength, since we can trust bLength,
this patch searches forward for a descriptor with type of LIBUSB_DT_CONFIG
to find the next config on sysfs.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
libusb/os/linux_usbfs.c
libusb/version_nano.h