]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
MIPS: Loongson2ef: Replace deprecated strncpy() with strscpy()
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 24 Feb 2025 21:54:50 +0000 (22:54 +0100)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Thu, 27 Feb 2025 09:40:01 +0000 (10:40 +0100)
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 <thorsten.blum@linux.dev>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/loongson2ef/common/machtype.c

index 82f6de49f20fe6bb1bc611819e3db5f0062273ff..e635e66d2e6c9c84685102b3086cf3c9730f7195 100644 (file)
@@ -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';