]> err.no Git - util-linux/commitdiff
fallocate: check for ERANGE errors
authorKarel Zak <kzak@redhat.com>
Tue, 6 Oct 2009 21:49:56 +0000 (23:49 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 6 Oct 2009 21:57:11 +0000 (23:57 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/fallocate.c

index 66e97649231e7efe13b4b85de1d50c98719be5b4..be715777b7e2d5e268f78d0335c6dc223b76d3e7 100644 (file)
@@ -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')