[PATCH] Use ULLONG_MAX when checking for strtoull overflow

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

 



From: Apollon Oikonomopoulos <apoikos@xxxxxxxxxx>

According to strtoull(3):

 [...] Precisely the same holds for strtoull() (with ULLONG_MAX instead
 of ULONG_MAX).

Since we are using strtoull(3) and not strtoul(3), the check should be
made against ULLONG_MAX. Note that at least on amd64 ULONG_MAX and
ULLONG_MAX are the same, but this is not guaranteed to be the case for
other architectures as well.

Signed-off-by: Apollon Oikonomopoulos <apoikos@xxxxxxxxxx>
---
 usr/util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr/util.h b/usr/util.h
index 019ff1c..256bdb8 100644
--- a/usr/util.h
+++ b/usr/util.h
@@ -148,7 +148,7 @@ struct signalfd_siginfo {
 	unsigned long long ull_val;     		\
 	ull_val = strtoull(str, &ptr, 0);       	\
 	val = (typeof(val)) ull_val;    		\
-	if (ull_val == ULONG_MAX || ptr == str)		\
+	if (ull_val == ULLONG_MAX || ptr == str)	\
 		ret = EINVAL;   			\
 	else if (val != ull_val)			\
 		ret = ERANGE;   			\
-- 
2.8.1

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



[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux