diff options
author | Wang Xiayang <xywang.sjtu@sjtu.edu.cn> | 2019-09-20 09:55:47 +0300 |
---|---|---|
committer | Ley Foon Tan <ley.foon.tan@intel.com> | 2019-09-20 09:55:57 +0300 |
commit | 91d99a724e9c60e14332c26ab2284bf696b94c8e (patch) | |
tree | b1063a99689b528be795a82943bbdf97ab69869a /arch/nios2 | |
parent | 4d856f72c10ecb060868ed10ff1b1453943fc6c8 (diff) | |
download | linux-91d99a724e9c60e14332c26ab2284bf696b94c8e.tar.xz |
nios2: force the string buffer NULL-terminated
strncpy() does not ensure NULL-termination when the input string
size equals to the destination buffer size COMMAND_LINE_SIZE.
Besides, grep under arch/ with 'boot_command_line' shows
no other arch-specific code uses strncpy() when copying
boot_command_line.
Use strlcpy() instead.
This issue is identified by a Coccinelle script.
Signed-off-by: Wang Xiayang <xywang.sjtu@sjtu.edu.cn>
Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
Diffstat (limited to 'arch/nios2')
-rw-r--r-- | arch/nios2/kernel/setup.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c index 6bbd4ae2beb0..4cf35b09c0ec 100644 --- a/arch/nios2/kernel/setup.c +++ b/arch/nios2/kernel/setup.c @@ -123,7 +123,7 @@ asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6, dtb_passed = r6; if (r7) - strncpy(cmdline_passed, (char *)r7, COMMAND_LINE_SIZE); + strlcpy(cmdline_passed, (char *)r7, COMMAND_LINE_SIZE); } #endif @@ -131,10 +131,10 @@ asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6, #ifndef CONFIG_CMDLINE_FORCE if (cmdline_passed[0]) - strncpy(boot_command_line, cmdline_passed, COMMAND_LINE_SIZE); + strlcpy(boot_command_line, cmdline_passed, COMMAND_LINE_SIZE); #ifdef CONFIG_NIOS2_CMDLINE_IGNORE_DTB else - strncpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); + strlcpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE); #endif #endif |