fsck: 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:
Karel Zak 2021-06-21 15:29:43 +02:00
parent fe4e122ab3
commit d8a42b67c8
1 changed files with 2 additions and 1 deletions

View File

@ -169,8 +169,9 @@ static int string_to_int(const char *s)
long l;
char *p;
errno = 0;
l = strtol(s, &p, 0);
if (*p || l == LONG_MIN || l == LONG_MAX || l < 0 || l > INT_MAX)
if (errno || *p || l == LONG_MIN || l == LONG_MAX || l < 0 || l > INT_MAX)
return -1;
return (int) l;