diff options
author | Zhao Hongjiang <zhaohongjiang@huawei.com> | 2013-06-09 04:57:58 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-19 05:10:29 -0400 |
commit | 117a0c5fc9c2d06045bd217385b2b39ea426b5a6 (patch) | |
tree | 5023fb469da9fc796e80a1fdb919a2cad0d4cedb | |
parent | 242ece22f0bd90e237365e51c5bd90a21693d6c3 (diff) |
sparc: kernel: using strlcpy() instead of strcpy()
'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>
-rw-r--r-- | arch/sparc/kernel/ds.c | 3 | ||||
-rw-r--r-- | arch/sparc/kernel/setup_32.c | 2 | ||||
-rw-r--r-- | arch/sparc/kernel/setup_64.c | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c index 75bb608c423e..5ef48dab5636 100644 --- a/arch/sparc/kernel/ds.c +++ b/arch/sparc/kernel/ds.c | |||
@@ -843,7 +843,8 @@ void ldom_reboot(const char *boot_command) | |||
843 | unsigned long len; | 843 | unsigned long len; |
844 | 844 | ||
845 | strcpy(full_boot_str, "boot "); | 845 | strcpy(full_boot_str, "boot "); |
846 | strcpy(full_boot_str + strlen("boot "), boot_command); | 846 | strlcpy(full_boot_str + strlen("boot "), boot_command, |
847 | sizeof(full_boot_str + strlen("boot "))); | ||
847 | len = strlen(full_boot_str); | 848 | len = strlen(full_boot_str); |
848 | 849 | ||
849 | if (reboot_data_supported) { | 850 | if (reboot_data_supported) { |
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c index 38bf80a22f02..1434526970a6 100644 --- a/arch/sparc/kernel/setup_32.c +++ b/arch/sparc/kernel/setup_32.c | |||
@@ -304,7 +304,7 @@ void __init setup_arch(char **cmdline_p) | |||
304 | 304 | ||
305 | /* Initialize PROM console and command line. */ | 305 | /* Initialize PROM console and command line. */ |
306 | *cmdline_p = prom_getbootargs(); | 306 | *cmdline_p = prom_getbootargs(); |
307 | strcpy(boot_command_line, *cmdline_p); | 307 | strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE); |
308 | parse_early_param(); | 308 | parse_early_param(); |
309 | 309 | ||
310 | boot_flags_init(*cmdline_p); | 310 | boot_flags_init(*cmdline_p); |
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c index 88a127b9c69e..13785547e435 100644 --- a/arch/sparc/kernel/setup_64.c +++ b/arch/sparc/kernel/setup_64.c | |||
@@ -555,7 +555,7 @@ void __init setup_arch(char **cmdline_p) | |||
555 | { | 555 | { |
556 | /* Initialize PROM console and command line. */ | 556 | /* Initialize PROM console and command line. */ |
557 | *cmdline_p = prom_getbootargs(); | 557 | *cmdline_p = prom_getbootargs(); |
558 | strcpy(boot_command_line, *cmdline_p); | 558 | strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE); |
559 | parse_early_param(); | 559 | parse_early_param(); |
560 | 560 | ||
561 | boot_flags_init(*cmdline_p); | 561 | boot_flags_init(*cmdline_p); |