From: Karel Zak Date: Mon, 21 Jun 2021 13:29:43 +0000 (+0200) Subject: fsck: check errno after strto..() X-Git-Tag: v2.37.1~53 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=b2db509d13482da329527dffced1218962aef9d6;p=thirdparty%2Futil-linux.git fsck: check errno after strto..() Addresses: https://github.com/karelzak/util-linux/issues/1356 Signed-off-by: Karel Zak --- diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c index fe114d7298..b0f9ccb8d5 100644 --- a/disk-utils/fsck.c +++ b/disk-utils/fsck.c @@ -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;