printk: use strscpy() to instead of strlcpy()
authorXu Panda <xu.panda@zte.com.cn>
Wed, 30 Nov 2022 08:01:41 +0000 (16:01 +0800)
committerPetr Mladek <pmladek@suse.com>
Thu, 1 Dec 2022 10:57:51 +0000 (11:57 +0100)
The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL terminated strings.

Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/202211301601416229001@zte.com.cn
kernel/printk/printk.c

index e4f1e74..eec87dd 100644 (file)
@@ -2391,7 +2391,7 @@ static int __add_preferred_console(char *name, int idx, char *options,
                return -E2BIG;
        if (!brl_options)
                preferred_console = i;
-       strlcpy(c->name, name, sizeof(c->name));
+       strscpy(c->name, name, sizeof(c->name));
        c->options = options;
        set_user_specified(c, user_specified);
        braille_set_options(c, brl_options);