From: Joe Hershberger Date: Fri, 28 Sep 2018 20:32:35 +0000 (-0500) Subject: udev: Allow acpi_index and index to be "0" X-Git-Tag: v240~642 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d81186ef4f6a888a70f20a1e73a812d6acb9e22f;p=thirdparty%2Fsystemd.git udev: Allow acpi_index and index to be "0" 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 --- diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 5341d378840..834172c3889 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -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