X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fudev%2Fudev-builtin-usb_id.c;h=dcb2468bf6c67f34522e9037f7fd3c67d908bc07;hp=7ce401d15253ac6c3081c18069ad6386b4bec458;hb=4dd1de72e8e7ece77e8831e77eea650de404af75;hpb=d5a89d7dc17a5ba5cf4fc71f82963c5c94a31c3d diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c index 7ce401d15..dcb2468bf 100644 --- a/src/udev/udev-builtin-usb_id.c +++ b/src/udev/udev-builtin-usb_id.c @@ -189,7 +189,7 @@ static int dev_if_packed_info(struct udev_device *dev, char *ifs_str, size_t len pos = 0; strpos = 0; ifs_str[0] = '\0'; - while (pos < sizeof(buf) && strpos+7 < len-2) { + while (pos < size && strpos+7 < len-2) { struct usb_interface_descriptor *desc; char if_str[8]; @@ -273,7 +273,7 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool instance_str[0] = '\0'; /* shortcut, if we are called directly for a "usb_device" type */ - if (udev_device_get_devtype(dev) != NULL && strcmp(udev_device_get_devtype(dev), "usb_device") == 0) { + if (udev_device_get_devtype(dev) != NULL && streq(udev_device_get_devtype(dev), "usb_device")) { dev_if_packed_info(dev, packed_if_str, sizeof(packed_if_str)); dev_usb = dev; goto fallback; @@ -431,6 +431,17 @@ fallback: const char *usb_serial; usb_serial = udev_device_get_sysattr_value(dev_usb, "serial"); + if (usb_serial) { + const unsigned char *p; + + /* http://msdn.microsoft.com/en-us/library/windows/hardware/gg487321.aspx */ + for (p = (unsigned char *)usb_serial; *p != '\0'; p++) + if (*p < 0x20 || *p > 0x7f || *p == ',') { + usb_serial = NULL; + break; + } + } + if (usb_serial) { util_replace_whitespace(usb_serial, serial_str, sizeof(serial_str)-1); util_replace_chars(serial_str, NULL);