Re: [PATCH] nios2: Replace strcpy() with strscpy() and simplify setup_cpuinfo()

From: Kees Cook
Date: Wed Apr 16 2025 - 15:32:26 EST


On Wed, Apr 16, 2025 at 09:09:07PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.
>
> Since the destination buffer has a fixed length, strscpy() automatically
> determines its size using sizeof() when the size argument is omitted.
> This makes the explicit size argument unnecessary - remove it.
>
> Now, combine both if-else branches using strscpy() and the same buffer
> into a single statement to simplify the code.
>
> No functional changes intended.
>
> Link: https://github.com/KSPP/linux/issues/88
> Cc: linux-hardening@xxxxxxxxxxxxxxx
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>

Reviewed-by: Kees Cook <kees@xxxxxxxxxx>

--
Kees Cook