aboutsummaryrefslogtreecommitdiff
path: root/lib/test_fortify/write_overflow-strlcpy-src.c
diff options
context:
space:
mode:
authorKees Cook <[email protected]>2024-01-10 15:54:41 -0800
committerKees Cook <[email protected]>2024-01-18 12:29:21 -0800
commite28b0359587fe4055c838698172de0530b511702 (patch)
tree705fa11038c9c4ba3af8a62098c665106e60e8e1 /lib/test_fortify/write_overflow-strlcpy-src.c
parentb0d326da462e20285236e11e4cbc32085de9f363 (diff)
bcachefs: 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(). Nothing checks the return value here, so a direct replacement with strspy() is possible. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [1] Link: https://github.com/KSPP/linux/issues/89 [2] Cc: Kent Overstreet <[email protected]> Cc: Brian Foster <[email protected]> Cc: <[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-strlcpy-src.c')
0 files changed, 0 insertions, 0 deletions