From fd6663ef973e708d6f59a757902413f9c257cefc Mon Sep 17 00:00:00 2001 From: Martin Pärtel Date: Sun, 15 Nov 2015 21:03:45 +0000 Subject: Fix overflow in parse_byte_count when "long" is 32-bit. --- src/misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/misc.c b/src/misc.c index 4442127..612ec82 100644 --- a/src/misc.c +++ b/src/misc.c @@ -125,7 +125,7 @@ int parse_byte_count(const char *str, double *result) { char* end; double base = strtod(str, &end); - long mul = 1; + long long mul = 1; if (*end == '\0') { mul = 1L; } else if (strcmp(end, "k") == 0) { @@ -135,7 +135,7 @@ int parse_byte_count(const char *str, double *result) } else if (strcmp(end, "G") == 0) { mul = 1024L * 1024L * 1024L; } else if (strcmp(end, "T") == 0) { - mul = 1024L * 1024L * 1024L * 1024L; + mul = 1024LL * 1024LL * 1024LL * 1024LL; } else { return 0; } -- cgit v1.2.3