Skip to content

Commit

Permalink
MIPS: Loongson2ef: Replace deprecated strncpy() with strscpy()
Browse files Browse the repository at this point in the history
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>
Thorsten Blum authored and Thomas Bogendoerfer committed Feb 27, 2025
1 parent 232085d commit 1bea9ab
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions arch/mips/loongson2ef/common/machtype.c
Original file line number Diff line number Diff line change
@@ -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';

0 comments on commit 1bea9ab

Please sign in to comment.