summaryrefslogtreecommitdiff
path: root/src/udev/udev-builtin-usb_id.c
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2013-02-17 19:55:15 +0100
committerKay Sievers <kay@vrfy.org>2013-02-17 21:16:08 +0100
commita2cbfd5916ee13b216a314826083e4c4e06930d1 (patch)
treee68a08ad0f30767ce54fbe92e130e6e96a16f886 /src/udev/udev-builtin-usb_id.c
parent02a6fc3ea69ba8801bc1864dd393d8df31559667 (diff)
udev: usb_id - ignore non-ASCII serial numbers
On Thu, Feb 7, 2013 at 3:52 PM, Robert Milasan <rmilasan@suse.com> wrote: > Hi, seems that using some strange usb devices with really bogus serial > numbers usb_id creates links with junk strings in it: > > /dev/disk/by-id/usb-TSSTcorp_BDDVDW_SE-506AB_㡒䍌䜶䉗ぁㄴ㌴†ँ-0:0 > > Initially was believed that usb_id is to blame, then the kernel, but it > turns out that really the usb cd/dvd drive has this bogus serial number: > > output from dmesg: > [ 538.200160] usb 1-2: new high-speed USB device number 5 using > ehci_hcd [ 538.335067] usb 1-2: New USB device found, idVendor=0e8d, > idProduct=1956 [ 538.335080] usb 1-2: New USB device strings: Mfr=1, > Product=2, SerialNumber=3 [ 538.335089] usb 1-2: Product: MT1956 > [ 538.335097] usb 1-2: Manufacturer: MediaTek Inc > [ 538.335105] usb 1-2: SerialNumber: > \xffffffe3\xffffffa1\xffffff92\xffffffe4\xffffff8d\xffffff8c ... > [ 538.337540] scsi6 : usb-storage 1-2:1.0 [ 539.341385] scsi 6:0:0:0: > CD-ROM TSSTcorp BDDVDW SE-506AB TS00 PQ: 0 ANSI: 0 > [ 539.354240] sr0: scsi3-mmc drive: 0x/24x writer dvd-ram cd/rw > xa/form2 cdda tray [ 539.354777] sr 6:0:0:0: Attached scsi CD-ROM sr0 > [ 539.355122] sr 6:0:0:0: Attached scsi generic sg2 type 5
Diffstat (limited to 'src/udev/udev-builtin-usb_id.c')
-rw-r--r--src/udev/udev-builtin-usb_id.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c
index 01e42ca7b1..ee83d4fde9 100644
--- a/src/udev/udev-builtin-usb_id.c
+++ b/src/udev/udev-builtin-usb_id.c
@@ -432,6 +432,17 @@ fallback:
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);
}