[systemd-devel] [PATCH] udev: Allow acpi_index and index to be "0"

Joe Hershberger joe.hershberger at ni.com
Fri Sep 28 20:46:05 UTC 2018


0 can be a valid index returned by the BIOS, so allow that literal while
still checking for 0 as a failed conversion by strtoul(). Also, unsigned
long cannot be negative, so don't misleadingly check for less than 0.

Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
---
 src/udev/udev-builtin-net_id.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index 5341d3788..338a2d4c4 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -232,7 +232,7 @@ static int dev_pci_onboard(struct udev_device *dev, struct netnames *names) {
                 return -ENOENT;
 
         idx = strtoul(attr, NULL, 0);
-        if (idx <= 0)
+        if (idx == 0 && strcmp("0", attr))
                 return -EINVAL;
 
         /* Some BIOSes report rubbish indexes that are excessively high (2^24-1 is an index VMware likes to report for
-- 
2.11.0



More information about the systemd-devel mailing list