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.hershber...@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

_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to