On Fri, Sep 28, 2018, 23:49 Joe Hershberger <joe.hershberger@xxxxxx> wrote:
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@xxxxxx>
---
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))
If error checking is needed, wouldn't it be better to use the error checking that strtoul itself provides?
("If endptr is not NULL, strtoul() stores the address of the first invalid character in *endptr.")
Mantas Mikulėnas
_______________________________________________ systemd-devel mailing list systemd-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/systemd-devel