[PATCH] m64k/kernel: replace strncpy() with strscpy()

Mohammad Mahdi Anbaraki posted 1 patch 10 months, 1 week ago
arch/m68k/kernel/uboot.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] m64k/kernel: replace strncpy() with strscpy()
Posted by Mohammad Mahdi Anbaraki 10 months, 1 week ago
Swapped out strncpy() for strscpy() in parse_uboot_commandline() while
copying to commandp. strscpy() makes sure the string is properly null-
terminated and gives a more useful return value so it's just a safer 
choice overall.

Link: https://github.com/KSPP/linux/issues/90
Signed-off-by: Mohammad Mahdi Anbaraki <m.mahdianbaraki@gmail.com>
---
 arch/m68k/kernel/uboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/kernel/uboot.c b/arch/m68k/kernel/uboot.c
index 5e52ea150..fa7c279ea 100644
--- a/arch/m68k/kernel/uboot.c
+++ b/arch/m68k/kernel/uboot.c
@@ -73,7 +73,7 @@ static void __init parse_uboot_commandline(char *commandp, int size)
 	uboot_cmd_end = sp[5];
 
 	if (uboot_cmd_start && uboot_cmd_end)
-		strncpy(commandp, (const char *)uboot_cmd_start, size);
+		strscpy(commandp, (const char *)uboot_cmd_start, size);
 
 #if defined(CONFIG_BLK_DEV_INITRD)
 	uboot_initrd_start = sp[2];
-- 
2.43.0
Re: [PATCH] m64k/kernel: replace strncpy() with strscpy()
Posted by Andreas Schwab 10 months, 1 week ago
s/m64k/m68k/

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."