Squashfs: remove deprecated strncpy by not copying the string
authorPhillip Lougher <phillip@squashfs.org.uk>
Wed, 3 Apr 2024 18:33:52 +0000 (19:33 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 26 Apr 2024 04:07:05 +0000 (21:07 -0700)
commit040bf9a717885d3646dcd5b4062dc3a4877ec421
tree9333ce6577292e6b4429e030636e14c0c916aa5a
parent029c45bb24d02a4de7b1e3866fe7592d59c10718
Squashfs: remove deprecated strncpy by not copying the string

Squashfs copied the passed string (name) into a temporary buffer to ensure
it was NUL-terminated.  This however is completely unnecessary as the
string is already NUL-terminated.  So remove the deprecated strncpy() by
completely removing the string copy.

The background behind this unnecessary string copy is that it dates back
to the days when Squashfs was an out of kernel patch.  The code
deliberately did not assume the string was NUL-terminated in case in
future this changed (due to kernel changes).  This would mean the out of
tree patches would be broken but still compile OK.

Link: https://lkml.kernel.org/r/20240403183352.391308-1-phillip@squashfs.org.uk
Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/squashfs/namei.c