nios2: Replace all non-returning strlcpy with strscpy
authorAzeem Shaikh <azeemshaikh38@gmail.com>
Tue, 30 May 2023 16:23:58 +0000 (16:23 +0000)
committerDinh Nguyen <dinguyen@kernel.org>
Tue, 13 Jun 2023 21:51:49 +0000 (16:51 -0500)
commit6a22e017f952ecaf4bb510cd0939259470a27b06
tree3cbfcd647a46bae5838e0213783e4a844d6f77c5
parent6ebe94baa2b9ddf3ccbb7f94df6ab26234532734
nios2: Replace all non-returning 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].
In an effort to remove strlcpy() completely [2], replace
strlcpy() here with strscpy().
No return values were used, so direct replacement is safe.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89

Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
arch/nios2/kernel/cpuinfo.c
arch/nios2/kernel/setup.c