summaryrefslogtreecommitdiffstats
path: root/sys-utils/fallocate.c
diff options
context:
space:
mode:
authorKarel Zak2009-10-06 23:49:56 +0200
committerKarel Zak2009-10-06 23:57:11 +0200
commit6264af59fd01ca38387bc4c7449b23c237f5b4ee (patch)
tree8ce84498fc5fff8c5091e3d0eee26e80ef4c3f1b /sys-utils/fallocate.c
parentwipefs: new command (diff)
downloadkernel-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.c6
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')