[PATCH] lib: vsprintf: fix invalid arg check

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

 



"size" is size_t.  If we want to check whether it was underflowed
then we should cast it to ssize_t instead of int.  When
sizeof(size_t) > sizeof(int) the code sees UINT_MAX as underflow,
but it is not.

Signed-off-by: Vasiliy Kulikov <segooon@xxxxxxxxx>
---
 Compile tested.

 lib/vsprintf.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index c150d3d..e7cf674 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1290,7 +1290,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 
 	/* Reject out-of-range values early.  Large positive sizes are
 	   used for unknown buffer sizes. */
-	if (WARN_ON_ONCE((int) size < 0))
+	if (WARN_ON_ONCE((ssize_t) size < 0))
 		return 0;
 
 	str = buf;
-- 
1.7.0.4

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


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux