From: Karel Zak Date: Tue, 6 Oct 2009 21:49:56 +0000 (+0200) Subject: fallocate: check for ERANGE errors X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6264af59fd01ca38387bc4c7449b23c237f5b4ee;p=util-linux fallocate: check for ERANGE errors Signed-off-by: Karel Zak --- diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c index 66e97649..be715777 100644 --- a/sys-utils/fallocate.c +++ b/sys-utils/fallocate.c @@ -31,6 +31,7 @@ #include #include #include +#include #ifndef HAVE_FALLOCATE # include @@ -69,7 +70,12 @@ static loff_t cvtnum(char *s) loff_t i; char *sp; + errno = 0; i = strtoll(s, &sp, 0); + + if ((errno == ERANGE && (i == LLONG_MAX || i == LLONG_MIN)) || + (errno != 0 && i == 0)) + return -1LL; if (i == 0 && sp == s) return -1LL; if (*sp == '\0')