mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 21:21:09 -04:00
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated[1]. Additionally, it returns the size of the source string, not the resulting size of the destination string. In an effort to remove strlcpy() completely[2], replace strlcpy() here with strscpy(). Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [1] Link: https://github.com/KSPP/linux/issues/89 [2] Cc: Masami Hiramatsu <[email protected]> Cc: Valentin Schneider <[email protected]> Cc: "Steven Rostedt (Google)" <[email protected]> Cc: Chuck Lever <[email protected]> Cc: Geliang Tang <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Christophe JAILLET <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Arnd Bergmann <[email protected]> Acked-by: "Steven Rostedt (Google)" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>