sparc: kernel: using strlcpy() instead of strcpy()
authorZhao Hongjiang <zhaohongjiang@huawei.com>
Sun, 9 Jun 2013 08:57:58 +0000 (16:57 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Jun 2013 09:10:29 +0000 (02:10 -0700)
'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>
arch/sparc/kernel/ds.c
arch/sparc/kernel/setup_32.c
arch/sparc/kernel/setup_64.c

index 75bb608c423eacb459321c5628ee45d6ce769ba6..5ef48dab563694db95935564e5df92172fd67bab 100644 (file)
@@ -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) {
index 38bf80a22f02396704fbb0f69ccef74fd83d689b..1434526970a6bf446a495d275eab9f46073a4172 100644 (file)
@@ -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);
index 88a127b9c69e8b1876a94b60db94456eca6fe5ef..13785547e435274bb6fa079968a9d516dc25800f 100644 (file)
@@ -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);