From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Thorsten Blum <thorsten.blum@linux.dev>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>,
linux-hardening@vger.kernel.org, linux-mips@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MIPS: Loongson2ef: Replace deprecated strncpy() with strscpy()
Date: Thu, 27 Feb 2025 11:04:01 +0100 [thread overview]
Message-ID: <Z8A4kVKXXgy5KskY@alpha.franken.de> (raw)
In-Reply-To: <20250224215451.195727-2-thorsten.blum@linux.dev>
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 ]
prev parent reply other threads:[~2025-02-27 10:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 21:54 [PATCH] MIPS: Loongson2ef: Replace deprecated strncpy() with strscpy() Thorsten Blum
2025-02-27 10:04 ` Thomas Bogendoerfer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z8A4kVKXXgy5KskY@alpha.franken.de \
--to=tsbogend@alpha.franken.de \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=thorsten.blum@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox