Re: [PATCH] m68k: mm: Replace deprecated strncpy() with strscpy()
From: Geert Uytterhoeven
Date: Tue Feb 18 2025 - 09:14:49 EST
On Thu, 13 Feb 2025 at 15:11, Thorsten Blum <thorsten.blum@xxxxxxxxx> wrote:
> strncpy() is deprecated for NUL-terminated destination buffers. Use
> strscpy() instead and remove the manual NUL-termination.
>
> Compile-tested only.
>
> Link: https://github.com/KSPP/linux/issues/90
> Cc: linux-hardening@xxxxxxxxxxxxxxx
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
Reviewed-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> --- a/arch/m68k/kernel/setup_mm.c
> +++ b/arch/m68k/kernel/setup_mm.c
> @@ -243,8 +243,7 @@ void __init setup_arch(char **cmdline_p)
> setup_initial_init_mm((void *)PAGE_OFFSET, _etext, _edata, _end);
>
> #if defined(CONFIG_BOOTPARAM)
> - strncpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE);
> - m68k_command_line[CL_SIZE - 1] = 0;
> + strscpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE);
> #endif /* CONFIG_BOOTPARAM */
> process_uboot_commandline(&m68k_command_line[0], CL_SIZE);
> *cmdline_p = m68k_command_line;
This seems to be used mostly by Coldfire, so I'll let Greg handle it.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds