* [PATCH] MIPS: Loongson2ef: Replace deprecated strncpy() with strscpy()
@ 2025-02-24 21:54 Thorsten Blum
2025-02-27 10:04 ` Thomas Bogendoerfer
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2025-02-24 21:54 UTC (permalink / raw)
To: Jiaxun Yang, Thomas Bogendoerfer
Cc: Thorsten Blum, linux-hardening, linux-mips, linux-kernel
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>
---
arch/mips/loongson2ef/common/machtype.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/mips/loongson2ef/common/machtype.c b/arch/mips/loongson2ef/common/machtype.c
index 82f6de49f20f..e635e66d2e6c 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';
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] MIPS: Loongson2ef: Replace deprecated strncpy() with strscpy()
2025-02-24 21:54 [PATCH] MIPS: Loongson2ef: Replace deprecated strncpy() with strscpy() Thorsten Blum
@ 2025-02-27 10:04 ` Thomas Bogendoerfer
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Bogendoerfer @ 2025-02-27 10:04 UTC (permalink / raw)
To: Thorsten Blum; +Cc: Jiaxun Yang, linux-hardening, linux-mips, linux-kernel
On Mon, Feb 24, 2025 at 10:54:50PM +0100, Thorsten Blum wrote:
> 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>
> ---
> arch/mips/loongson2ef/common/machtype.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/mips/loongson2ef/common/machtype.c b/arch/mips/loongson2ef/common/machtype.c
> index 82f6de49f20f..e635e66d2e6c 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';
> --
> 2.48.1
applied to mips-next.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-27 10:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-24 21:54 [PATCH] MIPS: Loongson2ef: Replace deprecated strncpy() with strscpy() Thorsten Blum
2025-02-27 10:04 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox