]> git.baikalelectronics.ru Git - kernel.git/commitdiff
x86/setup: Use strscpy() to replace deprecated strlcpy()
authorXueBing Chen <chenxuebing@jari.cn>
Wed, 25 May 2022 08:51:01 +0000 (16:51 +0800)
committerIngo Molnar <mingo@kernel.org>
Wed, 25 May 2022 13:34:38 +0000 (15:34 +0200)
strlcpy() is marked deprecated and should not be used, because
it doesn't limit the source length.

The preferred interface for when strlcpy()'s return value is not
checked (truncation) is strscpy().

[ mingo: Tweaked the changelog ]

Signed-off-by: XueBing Chen <chenxuebing@jari.cn>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/730f0fef.a33.180fa69880f.Coremail.chenxuebing@jari.cn
arch/x86/kernel/setup.c

index 249981bf3d8aa4a5a8e973142b7f81bb65d9f3db..3ebb85327edb1b5f21070e89c1bb939a87f42fa8 100644 (file)
@@ -903,18 +903,18 @@ void __init setup_arch(char **cmdline_p)
 
 #ifdef CONFIG_CMDLINE_BOOL
 #ifdef CONFIG_CMDLINE_OVERRIDE
-       strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+       strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
 #else
        if (builtin_cmdline[0]) {
                /* append boot loader cmdline to builtin */
                strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
                strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-               strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+               strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
        }
 #endif
 #endif
 
-       strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
+       strscpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
        *cmdline_p = command_line;
 
        /*