[systemd-commits] 4 commits - src/boot src/shared src/udev

Kay Sievers kay at kemper.freedesktop.org
Sun Feb 17 13:29:07 PST 2013


 src/boot/boot-efi.c            |    6 ++++++
 src/boot/bootctl.c             |    4 ++--
 src/shared/efivars.c           |    7 +------
 src/udev/udev-builtin-usb_id.c |   13 ++++++++++++-
 4 files changed, 21 insertions(+), 9 deletions(-)

New commits:
commit 71bf4f6f6c450e111795054e1bc50da692202c31
Author: Kay Sievers <kay at vrfy.org>
Date:   Sun Feb 17 22:28:21 2013 +0100

    bootctl: show "n/a" for empty boot option labels

diff --git a/src/boot/boot-efi.c b/src/boot/boot-efi.c
index faa8680..51f12c0 100644
--- a/src/boot/boot-efi.c
+++ b/src/boot/boot-efi.c
@@ -75,7 +75,13 @@ static int get_boot_entries(struct boot_info *info) {
                 err = efi_get_boot_option(list[i], &e->title, &e->part_uuid, &e->path);
                 if (err < 0)
                         continue;
+
+                if (isempty(e->title)) {
+                        free(e->title);
+                        e->title = NULL;
+                }
                 tilt_slashes(e->path);
+
                 e->id = list[i];
                 info->fw_entries_count++;
         }
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
index 2f1f643..2a42898 100644
--- a/src/boot/bootctl.c
+++ b/src/boot/bootctl.c
@@ -149,7 +149,7 @@ static int show_status(char **args, unsigned n) {
                 printf("      Firmware: %s (%s)\n", info->fw_type, strna(info->fw_info));
 
         if (info->fw_entry_active >= 0) {
-                printf("Firmware entry: %s\n", info->fw_entries[info->fw_entry_active].title);
+                printf("Firmware entry: %s\n", strna(info->fw_entries[info->fw_entry_active].title));
                 if (info->fw_entries[info->fw_entry_active].path)
                         printf("                %s\n", info->fw_entries[info->fw_entry_active].path);
                 if (!sd_id128_equal(info->fw_entries[info->fw_entry_active].part_uuid, SD_ID128_NULL))
@@ -165,7 +165,7 @@ static int show_status(char **args, unsigned n) {
                                SD_ID128_FORMAT_VAL(info->loader_part_uuid));
 
                 if (info->loader_entry_active >= 0) {
-                        printf("  Loader entry: %s\n", info->loader_entries[info->loader_entry_active].title);
+                        printf("  Loader entry: %s\n", strna(info->loader_entries[info->loader_entry_active].title));
                         printf("                %s\n", info->loader_entries[info->loader_entry_active].path);
                 }
 

commit 7962afbba9016ea03d9f2987fee341443fcde39d
Author: Kay Sievers <kay at vrfy.org>
Date:   Sun Feb 17 21:16:56 2013 +0100

    udev: usb_id: parse only 'size' bytes of the 'descriptors' buffer

diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c
index ee83d4f..dcb2468 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];
 

commit a2cbfd5916ee13b216a314826083e4c4e06930d1
Author: Kay Sievers <kay at vrfy.org>
Date:   Sun Feb 17 19:55:15 2013 +0100

    udev: usb_id - ignore non-ASCII serial numbers
    
    On Thu, Feb 7, 2013 at 3:52 PM, Robert Milasan <rmilasan at 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

diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c
index 01e42ca..ee83d4f 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);
                 }

commit 02a6fc3ea69ba8801bc1864dd393d8df31559667
Author: Kay Sievers <kay at vrfy.org>
Date:   Sun Feb 17 19:54:29 2013 +0100

    efi: compare by substraction

diff --git a/src/shared/efivars.c b/src/shared/efivars.c
index 8494f37..c42956f 100644
--- a/src/shared/efivars.c
+++ b/src/shared/efivars.c
@@ -308,12 +308,7 @@ static int boot_id_hex(const char s[4]) {
 static int cmp_uint16(const void *_a, const void *_b) {
         const uint16_t *a = _a, *b = _b;
 
-        if (*a < *b)
-                return -1;
-        if (*a > *b)
-                return 1;
-
-        return 0;
+        return (int)*a - (int)*b;
 }
 
 int efi_get_boot_options(uint16_t **options) {



More information about the systemd-commits mailing list