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

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

 



On Sun, Nov 30, 2014 at 01:57:35PM +0000, Sami Kerola wrote:
> 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)

Really? (size_t) -1 and (size_t) -2 are by libc API defined return
codes. It would be better to keep it in code.

    Karel


-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
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