linux: Clear descriptor buffer before read when using usbfs
authorHans de Goede <hdegoede@redhat.com>
Wed, 22 May 2013 12:52:37 +0000 (14:52 +0200)
committerHans de Goede <hdegoede@redhat.com>
Thu, 23 May 2013 10:57:28 +0000 (12:57 +0200)
commit24b63efe460b56559437c44a21f9d4b034e8dca8
treebd8b452201ffdbae2d8def85b9b227e8e3b3b477
parentaf9997c4085ed0c26b022070ce9f5e19cd8cfec4
linux: Clear descriptor buffer before read when using usbfs

In usbfs the config descriptors are config.wTotalLength bytes apart, but the
device may actually return a shorter descriptor then advertised, in this
case the kernel will simply skip over any bytes read which the device did
not actually return. Note the kernel will *not* return 0 data, it will simply
leave the memory passed in to the read call as is.

Therefor this patch clears the buffer before calling read, to ensure that
the non existing parts of the descriptors are always properly zero-ed.

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