* [PATCH] m68k: Replace memcpy() + manual NUL-termination with strscpy()
@ 2025-04-15 7:24 Thorsten Blum
2025-04-27 23:52 ` Greg Ungerer
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2025-04-15 7:24 UTC (permalink / raw)
To: Greg Ungerer, Geert Uytterhoeven; +Cc: Thorsten Blum, linux-m68k, linux-kernel
Use strscpy() to safely copy the command-line string instead of memcpy()
followed by a manual NUL-termination.
The source string is also NUL-terminated and meets the __must_be_cstr()
requirement of strscpy().
No functional changes intended.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
arch/m68k/kernel/setup_no.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c
index f9872098f5ca..f724875b15cc 100644
--- a/arch/m68k/kernel/setup_no.c
+++ b/arch/m68k/kernel/setup_no.c
@@ -145,8 +145,7 @@ void __init setup_arch(char **cmdline_p)
/* Keep a copy of command line */
*cmdline_p = &command_line[0];
- memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
- boot_command_line[COMMAND_LINE_SIZE-1] = 0;
+ strscpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
/*
* Give all the memory to the bootmap allocator, tell it to put the
--
2.49.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] m68k: Replace memcpy() + manual NUL-termination with strscpy()
2025-04-15 7:24 [PATCH] m68k: Replace memcpy() + manual NUL-termination with strscpy() Thorsten Blum
@ 2025-04-27 23:52 ` Greg Ungerer
0 siblings, 0 replies; 2+ messages in thread
From: Greg Ungerer @ 2025-04-27 23:52 UTC (permalink / raw)
To: Thorsten Blum, Geert Uytterhoeven; +Cc: linux-m68k, linux-kernel
Hi Thorsten,
On 15/4/25 17:24, Thorsten Blum wrote:
> Use strscpy() to safely copy the command-line string instead of memcpy()
> followed by a manual NUL-termination.
>
> The source string is also NUL-terminated and meets the __must_be_cstr()
> requirement of strscpy().
>
> No functional changes intended.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Thanks, applied to m68knommu git tree, for-next branch.
Regards
Greg
> ---
> arch/m68k/kernel/setup_no.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/m68k/kernel/setup_no.c b/arch/m68k/kernel/setup_no.c
> index f9872098f5ca..f724875b15cc 100644
> --- a/arch/m68k/kernel/setup_no.c
> +++ b/arch/m68k/kernel/setup_no.c
> @@ -145,8 +145,7 @@ void __init setup_arch(char **cmdline_p)
>
> /* Keep a copy of command line */
> *cmdline_p = &command_line[0];
> - memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
> - boot_command_line[COMMAND_LINE_SIZE-1] = 0;
> + strscpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
>
> /*
> * Give all the memory to the bootmap allocator, tell it to put the
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-27 23:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-15 7:24 [PATCH] m68k: Replace memcpy() + manual NUL-termination with strscpy() Thorsten Blum
2025-04-27 23:52 ` Greg Ungerer
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).