Skip to content

Commit

Permalink
sparc: kernel: using strlcpy() instead of strcpy()
Browse files Browse the repository at this point in the history
'boot_command_line' and 'full_boot_str' has a fix length, 'cmdline_p' and
'boot_command' maybe larger than them. So use strlcpy() instead of strcpy()
to avoid memory overflow.

Signed-off-by: Zhao Hongjiang <zhaohongjiang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Zhao Hongjiang authored and David S. Miller committed Jun 19, 2013
1 parent 242ece2 commit 117a0c5
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion arch/sparc/kernel/ds.c
Original file line number Diff line number Diff line change
@@ -843,7 +843,8 @@ void ldom_reboot(const char *boot_command)
unsigned long len;

strcpy(full_boot_str, "boot ");
strcpy(full_boot_str + strlen("boot "), boot_command);
strlcpy(full_boot_str + strlen("boot "), boot_command,
sizeof(full_boot_str + strlen("boot ")));
len = strlen(full_boot_str);

if (reboot_data_supported) {
2 changes: 1 addition & 1 deletion arch/sparc/kernel/setup_32.c
Original file line number Diff line number Diff line change
@@ -304,7 +304,7 @@ void __init setup_arch(char **cmdline_p)

/* Initialize PROM console and command line. */
*cmdline_p = prom_getbootargs();
strcpy(boot_command_line, *cmdline_p);
strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
parse_early_param();

boot_flags_init(*cmdline_p);
2 changes: 1 addition & 1 deletion arch/sparc/kernel/setup_64.c
Original file line number Diff line number Diff line change
@@ -555,7 +555,7 @@ void __init setup_arch(char **cmdline_p)
{
/* Initialize PROM console and command line. */
*cmdline_p = prom_getbootargs();
strcpy(boot_command_line, *cmdline_p);
strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
parse_early_param();

boot_flags_init(*cmdline_p);

0 comments on commit 117a0c5

Please sign in to comment.