summaryrefslogtreecommitdiffstats
path: root/libusbhost
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@google.com>2015-06-18 13:38:31 -0700
committerMike Lockwood <lockwood@google.com>2015-06-18 13:38:31 -0700
commit0dd1aab7b5184f41ec838def8493d16cfe70b739 (patch)
treed07fbfe95fc07225af9b4a156568d5f5ce792737 /libusbhost
parentd50393057a6551c3bb498ed3a3bb7bd9eeb48225 (diff)
downloadsystem_core-0dd1aab7b5184f41ec838def8493d16cfe70b739.zip
system_core-0dd1aab7b5184f41ec838def8493d16cfe70b739.tar.gz
system_core-0dd1aab7b5184f41ec838def8493d16cfe70b739.tar.bz2
libusbhost: Fix problem reading USB string descriptors on some quirky devices
Some devices fail to send USB string descriptors if you attempt to read more than 255 bytes Bug: 21871761 Change-Id: Id5b8865179f80523f0ad5b6028d49dd99db2b36b
Diffstat (limited to 'libusbhost')
-rw-r--r--libusbhost/usbhost.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libusbhost/usbhost.c b/libusbhost/usbhost.c
index 40b8b9f..b8e3215 100644
--- a/libusbhost/usbhost.c
+++ b/libusbhost/usbhost.c
@@ -56,6 +56,9 @@
#define USB_FS_ID_SCANNER USB_FS_DIR "/%d/%d"
#define USB_FS_ID_FORMAT USB_FS_DIR "/%03d/%03d"
+// Some devices fail to send string descriptors if we attempt reading > 255 bytes
+#define MAX_STRING_DESCRIPTOR_LENGTH 255
+
// From drivers/usb/core/devio.c
// I don't know why this isn't in a kernel header
#define MAX_USBFS_BUFFER_SIZE 16384
@@ -449,8 +452,8 @@ const struct usb_device_descriptor* usb_device_get_device_descriptor(struct usb_
char* usb_device_get_string(struct usb_device *device, int id)
{
char string[256];
- __u16 buffer[128];
- __u16 languages[128];
+ __u16 buffer[MAX_STRING_DESCRIPTOR_LENGTH / sizeof(__u16)];
+ __u16 languages[MAX_STRING_DESCRIPTOR_LENGTH / sizeof(__u16)];
int i, result;
int languageCount = 0;