[PATCH 03/10] more: fix unsigned integer overflow [AddressSanitizer]

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

 



text-utils/more.c:1137:20: runtime error: unsigned integer overflow: 0 -
1 cannot be represented in type 'size_t' (aka 'unsigned long')
text-utils/more.c:1139:7: runtime error: unsigned integer overflow: 2 +
18446744073709551615 cannot be represented in type 'unsigned long'

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 text-utils/more.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/text-utils/more.c b/text-utils/more.c
index a489953..4b03e0d 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -1125,14 +1125,14 @@ void prbuf(register char *s, register int n)
 #ifdef HAVE_WIDECHAR
 			{
 				wchar_t wc;
-				size_t mblength;
+				ssize_t mblength;
 				mbstate_t mbstate;
 				memset(&mbstate, '\0', sizeof(mbstate_t));
 				s--;
 				n++;
 				mblength = mbrtowc(&wc, s, n, &mbstate);
-				if (mblength == (size_t)-2
-				    || mblength == (size_t)-1)
+				if (mblength == -2
+				    || mblength == -1)
 					mblength = 1;
 				while (mblength--)
 					putchar(*s++);
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe util-linux" 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