]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fsck: check errno after strto..()
authorKarel Zak <kzak@redhat.com>
Mon, 21 Jun 2021 13:29:43 +0000 (15:29 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 21 Jun 2021 13:29:43 +0000 (15:29 +0200)
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fsck.c

index d76689e04e8547cbaa510f0f91a77b7641784251..135d48988ab7407f1b600395448756da96dcda34 100644 (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;