mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: feng.wei8@zte.com.cn, tglx@linutronix.de
Cc: darwi@linutronix.de, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tools/x86/kcpuid: Replace deprecated strncpy() with strscpy()
Date: Mon, 17 Mar 2025 09:51:39 +0100	[thread overview]
Message-ID: <27c4a0ab-a311-4d80-951a-b7912661c463@kernel.org> (raw)
In-Reply-To: <20250317153224647OjWUNNAviyd634961gnCh@zte.com.cn>

On 17. 03. 25, 8:32, feng.wei8@zte.com.cn wrote:
> From: FengWei <feng.wei8@zte.com.cn>
> 
> strncpy() is deprecated for NUL-terminated destination buffers. Use
> strscpy() instead and remove the manual NUL-termination.
> 
> Signed-off-by: FengWei <feng.wei8@zte.com.cn>
> ---
>   tools/arch/x86/kcpuid/kcpuid.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c
> index 1b25c0a95d3f..23a8fde2e203 100644
> --- a/tools/arch/x86/kcpuid/kcpuid.c
> +++ b/tools/arch/x86/kcpuid/kcpuid.c
> @@ -312,8 +312,7 @@ static int parse_line(char *line)
>   	if (line[0] == '#' || line[0] == '\n')
>   		return 0;
> 
> -	strncpy(buffer, line, 511);
> -	buffer[511] = 0;
> +	strscpy(buffer, line, 511);

Mind you this is userspace?

-- 
js
suse labs


      reply	other threads:[~2025-03-17  8:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-17  7:32 feng.wei8
2025-03-17  8:51 ` Jiri Slaby [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=27c4a0ab-a311-4d80-951a-b7912661c463@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=darwi@linutronix.de \
    --cc=feng.wei8@zte.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®