linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] m68k: replace deprecated strncpy with strscpy
@ 2025-04-17 20:10 Shankari02
  2025-04-21 13:01 ` Jean-Michel Hautbois
  2025-04-22  6:53 ` Geert Uytterhoeven
  0 siblings, 2 replies; 6+ messages in thread
From: Shankari02 @ 2025-04-17 20:10 UTC (permalink / raw)
  To: linux-m68k; +Cc: geert, jeanmichel.hautbois, Shankari02

The use of strncpy() does not guarantee NUL-termination and is deprecated
in the Linux kernel. This code manually terminates the buffer afterward,
but using strscpy() is simpler and safer.

This change replaces the strncpy() + NUL termination pattern with strscpy().

Signed-off-by: Shankari Anand <shankari.ak0208@gmail.com>
---
 arch/m68k/kernel/setup_mm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c
index 15c1a595a1de..48ce67947678 100644
--- 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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] m68k: replace deprecated strncpy with strscpy
@ 2025-04-16  5:31 Shankari02
  0 siblings, 0 replies; 6+ messages in thread
From: Shankari02 @ 2025-04-16  5:31 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-m68k, skhan, Shankari02

The use of strncpy() does not guarantee NUL-termination and is deprecated
in the Linux kernel. This code manually terminates the buffer afterward,
but using strscpy() is simpler and safer.

This change replaces the strncpy() + NUL termination pattern with strscpy().

Signed-off-by: Shankari Anand <shankari.ak0208@gmail.com>
---
 arch/m68k/kernel/setup_mm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c
index 15c1a595a1de..48ce67947678 100644
--- 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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-04-23 15:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-17 20:10 [PATCH] m68k: replace deprecated strncpy with strscpy Shankari02
2025-04-21 13:01 ` Jean-Michel Hautbois
2025-04-21 21:00   ` Jean-Michel Hautbois
2025-04-22  6:53 ` Geert Uytterhoeven
     [not found]   ` <CAPRMd3m2UmfPrzD2eXW9s_Uc1kM4cwCB4pMAbSSPX+MB85=H=A@mail.gmail.com>
2025-04-23 15:42     ` Shankari
  -- strict thread matches above, loose matches on Subject: below --
2025-04-16  5:31 Shankari02

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).