From 6264af59fd01ca38387bc4c7449b23c237f5b4ee Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 6 Oct 2009 23:49:56 +0200 Subject: [PATCH] fallocate: check for ERANGE errors Signed-off-by: Karel Zak --- sys-utils/fallocate.c | 6 ++++++ 1 file changed, 6 insertions(+) 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') -- 2.39.5