diff options
author | Karel Zak | 2009-10-06 23:49:56 +0200 |
---|---|---|
committer | Karel Zak | 2009-10-06 23:57:11 +0200 |
commit | 6264af59fd01ca38387bc4c7449b23c237f5b4ee (patch) | |
tree | 8ce84498fc5fff8c5091e3d0eee26e80ef4c3f1b /sys-utils/fallocate.c | |
parent | wipefs: new command (diff) | |
download | kernel-qcow2-util-linux-6264af59fd01ca38387bc4c7449b23c237f5b4ee.tar.gz kernel-qcow2-util-linux-6264af59fd01ca38387bc4c7449b23c237f5b4ee.tar.xz kernel-qcow2-util-linux-6264af59fd01ca38387bc4c7449b23c237f5b4ee.zip |
fallocate: check for ERANGE errors
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/fallocate.c')
-rw-r--r-- | sys-utils/fallocate.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c index 66e976492..be715777b 100644 --- a/sys-utils/fallocate.c +++ b/sys-utils/fallocate.c @@ -31,6 +31,7 @@ #include <unistd.h> #include <getopt.h> #include <err.h> +#include <limits.h> #ifndef HAVE_FALLOCATE # include <sys/syscall.h> @@ -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') |