diff options
author | Peter Wu <lekensteyn@gmail.com> | 2013-11-04 19:08:49 +0100 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2013-11-04 19:14:42 +0100 |
commit | 8e4ade500d01f59c21baf8e07d50f1c465df4328 (patch) | |
tree | 33262dbed15391673b2dace83424d5d7ab115634 /usbmisc.c | |
parent | 42737cf255e3b5b9d659646f397918b37e96a8de (diff) | |
download | usbutils-8e4ade500d01f59c21baf8e07d50f1c465df4328.tar.gz |
Ignore invalid string descriptors
This Ralink Wi-Fi adapter reports bogus values for some string
descriptors (iSerial and iInterface). As the current
libusb_get_string_descriptor function from 1.0.17 does not validate the
length or type and returns 254 even if the descriptor says 0, explicitly
check the fields before proceeding.
Fixes the following crash:
lsusb: gconv.c:74: __gconv: Assertion `outbuf != ((void *)0) && *outbuf != ((void *)0)' failed.
libusbx bug: https://github.com/libusbx/libusbx/pull/156
Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Diffstat (limited to 'usbmisc.c')
-rw-r--r-- | usbmisc.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -229,6 +229,9 @@ char *get_dev_string(libusb_device_handle *dev, u_int8_t id) sizeof unicode_buf); if (ret < 2) return strdup("(error)"); + if (unicode_buf[0] < 2 || unicode_buf[1] != LIBUSB_DT_STRING) + return strdup("(error)"); + buf = usb_string_to_native(unicode_buf + 2, ((unsigned char) unicode_buf[0] - 2) / 2); |