From: Thorsten Blum Date: Mon, 24 Feb 2025 21:54:50 +0000 (+0100) Subject: MIPS: Loongson2ef: Replace deprecated strncpy() with strscpy() X-Git-Tag: v6.15-rc1~112^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1bea9ab46d9f9871b71b078192699fc94287fcc4;p=thirdparty%2Flinux.git MIPS: Loongson2ef: Replace deprecated strncpy() with strscpy() strncpy() is deprecated for NUL-terminated destination buffers. Use strscpy() instead and remove the manual NUL-termination. Compile-tested only. Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Thorsten Blum Signed-off-by: Thomas Bogendoerfer --- diff --git a/arch/mips/loongson2ef/common/machtype.c b/arch/mips/loongson2ef/common/machtype.c index 82f6de49f20fe..e635e66d2e6c9 100644 --- a/arch/mips/loongson2ef/common/machtype.c +++ b/arch/mips/loongson2ef/common/machtype.c @@ -48,8 +48,7 @@ void __init prom_init_machtype(void) return; } p += strlen("machtype="); - strncpy(str, p, MACHTYPE_LEN); - str[MACHTYPE_LEN] = '\0'; + strscpy(str, p); p = strstr(str, " "); if (p) *p = '\0';