[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211220081917.922068-1-wangborong@cdjrlc.com>
Date: Mon, 20 Dec 2021 16:19:17 +0800
From: Jason Wang <wangborong@...rlc.com>
To: davem@...emloft.net
Cc: viro@...iv.linux.org.uk, wangborong@...rlc.com,
sparclinux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] sparc32: use strscpy to copy strings
The strlcpy should not be used because it doesn't limit the source
length. So that it will lead some potential bugs.
But the strscpy doesn't require reading memory from the src string
beyond the specified "count" bytes, and since the return value is
easier to error-check than strlcpy()'s. In addition, the implementation
is robust to the string changing out from underneath it, unlike the
current strlcpy() implementation.
Thus, replace strlcpy with strscpy.
Signed-off-by: Jason Wang <wangborong@...rlc.com>
---
arch/sparc/kernel/setup_32.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c
index c8e0dd99f370..c3fd44b7fd1a 100644
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -120,7 +120,7 @@ static struct console prom_early_console = {
.index = -1,
};
-/*
+/*
* Process kernel command line switches that are specific to the
* SPARC or that require special low-level processing.
*/
@@ -302,7 +302,7 @@ void __init setup_arch(char **cmdline_p)
/* Initialize PROM console and command line. */
*cmdline_p = prom_getbootargs();
- strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
+ strscpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
parse_early_param();
boot_flags_init(*cmdline_p);
--
2.34.1
Powered by blists - more mailing lists