* [musl] Re: [PATCH] wcpcpy: Replace call of vulnerable function
[not found] <20240324170732.26096-1-maks.mishinFZ@gmail.com>
@ 2024-03-24 17:47 ` Rich Felker
0 siblings, 0 replies; only message in thread
From: Rich Felker @ 2024-03-24 17:47 UTC (permalink / raw)
To: Maks Mishin; +Cc: musl
On Sun, Mar 24, 2024 at 08:07:32PM +0300, Maks Mishin wrote:
> Use of vulnerable function 'wcscpy' at wcpcpy.c:5.
> This function is unsafe, use 'wcsncpy' instead.
>
> Found by RASU JSC.
>
> Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
> ---
> src/string/wcpcpy.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/string/wcpcpy.c b/src/string/wcpcpy.c
> index ef401343..53a29a99 100644
> --- a/src/string/wcpcpy.c
> +++ b/src/string/wcpcpy.c
> @@ -2,5 +2,5 @@
>
> wchar_t *wcpcpy(wchar_t *restrict d, const wchar_t *restrict s)
> {
> - return wcscpy(d, s) + wcslen(s);
> + return wcsncpy(d, s, sizeof d) + wcslen(s);
> }
> --
> 2.30.2
Also wrong for the exact same reasons as the sprintf one.
Rich
^ permalink raw reply [flat|nested] only message in thread