All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/setup: use strscpy to replace strlcpy
@ 2022-05-25  8:51 XueBing Chen
  2022-05-25 13:43 ` [tip: x86/boot] x86/setup: Use strscpy() to replace deprecated strlcpy() tip-bot2 for XueBing Chen
  0 siblings, 1 reply; 2+ messages in thread
From: XueBing Chen @ 2022-05-25  8:51 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86
  Cc: hpa, rppt, akpm, daniel.kiper, konrad, ross.philipson, jszhang,
	andriy.shevchenko, jgross, mlombard, linux-kernel


The strlcpy should not be used because it doesn't limit the source
length. Preferred is strscpy.

Signed-off-by: XueBing Chen <chenxuebing@jari.cn>
---
 arch/x86/kernel/setup.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index c95b9ac5a457..f95eaba2c8ad 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -879,18 +879,18 @@ void __init setup_arch(char **cmdline_p)
 
 #ifdef CONFIG_CMDLINE_BOOL
 #ifdef CONFIG_CMDLINE_OVERRIDE
-	strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+	strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
 #else
 	if (builtin_cmdline[0]) {
 		/* append boot loader cmdline to builtin */
 		strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
 		strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-		strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+		strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
 	}
 #endif
 #endif
 
-	strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
+	strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
 	*cmdline_p = command_line;
 
 	/*
-- 
2.36.1



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

* [tip: x86/boot] x86/setup: Use strscpy() to replace deprecated strlcpy()
  2022-05-25  8:51 [PATCH] x86/setup: use strscpy to replace strlcpy XueBing Chen
@ 2022-05-25 13:43 ` tip-bot2 for XueBing Chen
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for XueBing Chen @ 2022-05-25 13:43 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: XueBing Chen, Ingo Molnar, x86, linux-kernel

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     8a33d96bd178d5f49cc5c1898e4cda08e221d2db
Gitweb:        https://git.kernel.org/tip/8a33d96bd178d5f49cc5c1898e4cda08e221d2db
Author:        XueBing Chen <chenxuebing@jari.cn>
AuthorDate:    Wed, 25 May 2022 16:51:01 +08:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Wed, 25 May 2022 15:34:38 +02:00

x86/setup: Use strscpy() to replace deprecated strlcpy()

strlcpy() is marked deprecated and should not be used, because
it doesn't limit the source length.

The preferred interface for when strlcpy()'s return value is not
checked (truncation) is strscpy().

[ mingo: Tweaked the changelog ]

Signed-off-by: XueBing Chen <chenxuebing@jari.cn>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/730f0fef.a33.180fa69880f.Coremail.chenxuebing@jari.cn
---
 arch/x86/kernel/setup.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 249981b..3ebb853 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -903,18 +903,18 @@ void __init setup_arch(char **cmdline_p)
 
 #ifdef CONFIG_CMDLINE_BOOL
 #ifdef CONFIG_CMDLINE_OVERRIDE
-	strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+	strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
 #else
 	if (builtin_cmdline[0]) {
 		/* append boot loader cmdline to builtin */
 		strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
 		strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-		strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+		strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
 	}
 #endif
 #endif
 
-	strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
+	strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
 	*cmdline_p = command_line;
 
 	/*

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

end of thread, other threads:[~2022-05-25 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-25  8:51 [PATCH] x86/setup: use strscpy to replace strlcpy XueBing Chen
2022-05-25 13:43 ` [tip: x86/boot] x86/setup: Use strscpy() to replace deprecated strlcpy() tip-bot2 for XueBing Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.