]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: Allow acpi_index and index to be "0"
authorJoe Hershberger <joe.hershberger@ni.com>
Fri, 28 Sep 2018 20:32:35 +0000 (15:32 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 2 Oct 2018 20:58:15 +0000 (22:58 +0200)
0 can be a valid index returned by the BIOS, so allow that by using the
parsing function safe_atolu() to check for errors without excluding the
valid value "0".

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
src/udev/udev-builtin-net_id.c

index 5341d37884073fa3c8874a5370c2c4c0baf11e2a..834172c388953a763b0b02eab762dee2bb768c7e 100644 (file)
@@ -222,6 +222,7 @@ static int dev_pci_onboard(struct udev_device *dev, struct netnames *names) {
         const char *attr, *port_name;
         size_t l;
         char *s;
+        int r;
 
         /* ACPI _DSM  — device specific method for naming a PCI or PCI Express device */
         attr = udev_device_get_sysattr_value(names->pcidev, "acpi_index");
@@ -231,9 +232,9 @@ static int dev_pci_onboard(struct udev_device *dev, struct netnames *names) {
         if (!attr)
                 return -ENOENT;
 
-        idx = strtoul(attr, NULL, 0);
-        if (idx <= 0)
-                return -EINVAL;
+        r = safe_atolu(attr, &idx);
+        if (r < 0)
+                return r;
 
         /* Some BIOSes report rubbish indexes that are excessively high (2^24-1 is an index VMware likes to report for
          * example). Let's define a cut-off where we don't consider the index reliable anymore. We pick some arbitrary