aboutsummaryrefslogtreecommitdiff
path: root/lib/test_fortify/write_overflow-strncpy-src.c
diff options
context:
space:
mode:
authorKees Cook <[email protected]>2023-11-16 11:15:10 -0800
committerKees Cook <[email protected]>2023-11-30 12:20:53 -0800
commit40b2519d7566266d7eafd3c5232c73a497640bca (patch)
tree9dfc5c39966ded80e08f4666cb516887b13da08e /lib/test_fortify/write_overflow-strncpy-src.c
parentcb6d2fd30dddd00499333e9475f8b11bbd84f37c (diff)
samples: Replace strlcpy() with strscpy()
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]>
Diffstat (limited to 'lib/test_fortify/write_overflow-strncpy-src.c')
0 files changed, 0 insertions, 0 deletions