m68k/kernel: replace strncpy() with strscpy()
PATCH v2 1/1 m68k/kernel: replace strncpy() with strscpy()
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.
---
Changes in v2:
- s/m64/m68
arch/m68k/kernel/uboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/kernel/uboot.c +1 -1
@@ -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 ];
Signature · 1 line
2.43.0
Hi
.Just a gentle follow-up on this patch
/s/m64k/m68k
Mohammad Mahdi Anbaraki <[email protected]> در تاریخ پنجشنبه ۳ آوریل ۲۰۲۵ ساعت ۲۱:۴۲ نوشت:
Quoted 31 lines
Swapped out
strncpy()forstrscpy()inparse_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.Signed-off-by Mohammad Mahdi Anbaraki <[email protected]>---
Changes in v2:
- s/m64/m68arch/m68k/kernel/uboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/m68k/kernel/uboot.c +1
-2@@ -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
Hi Homammad,
Quoted 7 lines · Mohammad Mahdi Anbaraki
Swapped out
strncpy()forstrscpy()inparse_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.
Thanks. Seeing as this only affects nommu/coldfire I will apply this to the m68knommu git tree, for-next branch.
Regards
Greg
Quoted 20 lines
---
Changes in v2:
- s/m64/m68arch/m68k/kernel/uboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/m68k/kernel/uboot.c +1
-1@@ -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 ];