RE: dmesg: fix segfqult

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

 



Marc-Antoine Perennou wrote:

> An element declared as size_t cannot be detected as negative (len < 0
> is always false).
> This can lead to an infinite loop causing a segmentation fault.
> Use an int to solve this issue
> 
> Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@xxxxxxxxxxxx>
> ---
>  sys-utils/dmesg.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
> index 867581d..91855a1 100644
> --- a/sys-utils/dmesg.c
> +++ b/sys-utils/dmesg.c
> @@ -362,7 +362,7 @@ static void safe_fwrite(const char *buf, size_t
> size, FILE *out)
> 
>  #ifdef HAVE_WIDECHAR
>  		wchar_t wc;
> -		size_t len = mbrtowc(&wc, p, size - i, &s);
> +		int len = mbrtowc(&wc, p, size - i, &s);
> 
>  		if (len == 0)				/* L'\0' */
>  			return;
> -- 
> 1.7.6.134.gcf13f6.dirty
> --

Interestingly, there are other projects which fell into the same trap:
* mc: https://bugzilla.redhat.com/show_bug.cgi?id=150569 

Have a nice day,
Berny
--
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