m68k: mm: Replace deprecated strncpy() with strscpy()
PATCH 1/1 m68k: mm: Replace deprecated strncpy() with strscpy()
strncpy() is deprecated for NUL-terminated destination buffers. Use strscpy() instead and remove the manual NUL-termination.
Compile-tested only.
--- arch/m68k/kernel/setup_mm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/m68k/kernel/setup_mm.c +1 -2
@@ -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;
Signature · 1 line
2.48.1
Hi Thorsten,
Quoted 8 lines · Thorsten Blum
strncpy()is deprecated for NUL-terminated destination buffers. Usestrscpy()instead and remove the manual NUL-termination.Compile-tested only.
Thanks for the patch !
It works fine for me:
Quoted 18 lines
--- arch/m68k/kernel/setup_mm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/m68k/kernel/setup_mm.c +1
-2@@ -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;
Quoted 8 lines · Thorsten Blum
strncpy()is deprecated for NUL-terminated destination buffers. Usestrscpy()instead and remove the manual NUL-termination.Compile-tested only.
arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 249
Quoted 12 lines
arch/m68k/kernel/setup_mm.c +1
-2@@ -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
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] 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
Hi Thorsten,
Quoted 17 lines · Geert Uytterhoeven
Quoted 8 lines · Thorsten Blum
strncpy()is deprecated for NUL-terminated destination buffers. Usestrscpy()instead and remove the manual NUL-termination.Compile-tested only.
Reviewed-by Geert Uytterhoeven <[email protected]>Quoted 5 lines
arch/m68k/kernel/setup_mm.c +0
-0@@ -243,8 +243,7 @@ void __init setup_arch(char **cmdline_p)setup_initial_init_mm ((void *)PAGE_OFFSET , _etext, _edata, _end);
Quoted 9 lines
arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 249
Quoted 7 lines
arch/m68k/kernel/setup_mm.c +1
-2#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.
Looks good. Pushed into the m68knommu git tree, for-next branch, with JM's tested-by and Geert's reviewed-by added.
Thanks
Greg
Quoted 17 lines · Thorsten Blum
strncpy()is deprecated for NUL-terminated destination buffers. Usestrscpy()instead and remove the manual NUL-termination.Compile-tested only.
Signed-off-by Thorsten Blum <[email protected]>--- arch/m68k/kernel/setup_mm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/m68k/kernel/setup_mm.c +0
-0
arch/m68k/kernel/setup_mm.c void __init setup_arch(char **cmdline_p) · line 249
Quoted 9 lines
arch/m68k/kernel/setup_mm.c +1
-2@@ -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;
m68k_command_line lives in rwdata, so it should be 0-initialized by default, so there should be no behavioral difference here (i.e. it will be zero-padded), and it is used as a C String, so there was unlikely to be anything depending on the NUL-padding.
Signature · 1 line
Kees Cook