Re: [PATCH] Squashfs: remove deprecated strncpy by not copying the string

From: Kees Cook
Date: Wed Apr 03 2024 - 17:28:46 EST


On Wed, Apr 03, 2024 at 07:33:52PM +0100, Phillip Lougher wrote:
> 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.
>
> Signed-off-by: Phillip Lougher <phillip@xxxxxxxxxxxxxxx>

Thanks!

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

--
Kees Cook