]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslogins: check errno after strto..()
authorKarel Zak <kzak@redhat.com>
Mon, 21 Jun 2021 13:31:43 +0000 (15:31 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 20 Jul 2021 09:34:53 +0000 (11:34 +0200)
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/lslogins.c

index 109e07fea8ea6932ac41dd8bd74932d5b911f899..d5e9638bfb777674661d0224b82f58352fad6b3f 100644 (file)
@@ -908,11 +908,14 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
 
 static int str_to_uint(char *s, unsigned int *ul)
 {
-       char *end;
+       char *end = NULL;
+
        if (!s || !*s)
                return -1;
+
+       errno = 0;
        *ul = strtoul(s, &end, 0);
-       if (!*end)
+       if (errno == 0 && end && !*end)
                return 0;
        return 1;
 }