]> 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>
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>
disk-utils/fsck.c

index fe114d729889872689404b3565a10c15b4321ea7..b0f9ccb8d5f1d55e04cc0fa3aff67d1ff1757e14 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;