Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240324175043.GC32430@brightrain.aerifal.cx>
Date: Sun, 24 Mar 2024 13:50:43 -0400
From: Rich Felker <dalias@...ifal.cx>
To: Maks Mishin <maks.mishinfz@...il.com>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH] wcscat: Replace call of vulnerable function

On Sun, Mar 24, 2024 at 08:26:27PM +0300, Maks Mishin wrote:
> Use of vulnerable function 'wcscpy' at wcscat.c:5.
> This function is unsafe, use wcsncpy instead.
> 
> Found by RASU JSC.
> 
> Signed-off-by: Maks Mishin <maks.mishinFZ@...il.com>
> ---
>  src/string/wcscat.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/string/wcscat.c b/src/string/wcscat.c
> index d4f00ebd..b4e4b2eb 100644
> --- a/src/string/wcscat.c
> +++ b/src/string/wcscat.c
> @@ -2,6 +2,6 @@
>  
>  wchar_t *wcscat(wchar_t *restrict dest, const wchar_t *restrict src)
>  {
> -	wcscpy(dest + wcslen(dest), src);
> +	wcsncpy(dest + wcslen(dest), src, sizeof dest);
>  	return dest;
>  }
> -- 
> 2.30.2

Wrong for same reason as the sprintf one.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.