[PATCH 1/2] mkswap: fixed strtoll() usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- catch empty string
- check against LLONG_MAX and LLONG_MIN instead of ULLONG_MAX and 0

Signed-off-by: Yann Droneaud <yann@xxxxxxxxxxx>

---
 disk-utils/mkswap.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index bc6c1d2..2bf07dd 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -565,8 +565,9 @@ main(int argc, char ** argv) {
 
 		errno = 0;
 		blks = strtoll(block_count, &tmp, 0);
-		if ((tmp && *tmp) ||
-		    (errno != 0 && (blks == ULLONG_MAX || blks == 0)) ||
+		if ((tmp == block_count) ||
+		    (tmp && *tmp) ||
+		    (errno != 0 && (blks == LLONG_MAX || blks == LLONG_MIN)) ||
 		    blks < 0)
 			usage();
 
-- 
1.6.2.5

--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux