lslogins: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
b2db509d13
commit
21ef212a58
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue