summaryrefslogtreecommitdiff
path: root/usbmisc.c
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-11-04 19:08:49 +0100
committerPeter Wu <lekensteyn@gmail.com>2013-11-04 19:14:42 +0100
commit8e4ade500d01f59c21baf8e07d50f1c465df4328 (patch)
tree33262dbed15391673b2dace83424d5d7ab115634 /usbmisc.c
parent42737cf255e3b5b9d659646f397918b37e96a8de (diff)
downloadusbutils-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.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/usbmisc.c b/usbmisc.c
index d5e7a31..f3577ea 100644
--- a/usbmisc.c
+++ b/usbmisc.c
@@ -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);