Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: xu.panda668@gmail.com
Cc: catalin.marinas@arm.com, broonie@kernel.org, maz@kernel.org,
	kristina.martsenko@arm.com, vladimir.murzin@arm.com,
	mark.rutland@arm.com, ardb@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, cgel.zte@gmail.com,
	Xu Panda <xu.panda@zte.com.cn>, Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH linux-next] arm64/idreg: use strscpy() is more robust and safer
Date: Tue, 4 Oct 2022 12:48:19 +0100	[thread overview]
Message-ID: <20221004114818.GA23663@willie-the-truck> (raw)
In-Reply-To: <20220929072905.282639-1-xu.panda668@gmail.com>

On Thu, Sep 29, 2022 at 07:29:06AM +0000, xu.panda668@gmail.com wrote:
> From: Xu Panda <xu.panda@zte.com.cn>
> 
> The implementation of strscpy() is more robust and safer.
> That's now the recommended way to copy NUL terminated strings.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
> Signed-off-by: Xu Panda <xu.panda668@gmail.com>
> ---
>  arch/arm64/kernel/idreg-override.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c
> index 95133765ed29..61bbec7ef62e 100644
> --- a/arch/arm64/kernel/idreg-override.c
> +++ b/arch/arm64/kernel/idreg-override.c
> @@ -246,7 +246,7 @@ static __init void __parse_cmdline(const char *cmdline, bool parse_aliases)
>                         return;
> 
>                 len = min(len, ARRAY_SIZE(buf) - 1);
> -               strncpy(buf, cmdline, len);
> +               strscpy(buf, cmdline, len);
>                 buf[len] = 0;

Aren't we terminating the buffer explicitly here anyway?

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-10-04 11:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-29  7:29 [PATCH linux-next] arm64/idreg: use strscpy() is more robust and safer xu.panda668
2022-10-04 11:48 ` Will Deacon [this message]
2022-10-05 13:57   ` David Laight
  -- strict thread matches above, loose matches on Subject: below --
2022-09-29  7:10 cgel.zte
2022-09-29  6:51 cgel.zte

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=20221004114818.GA23663@willie-the-truck \
    --to=will@kernel.org \
    --cc=ardb@kernel.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=cgel.zte@gmail.com \
    --cc=kristina.martsenko@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=vladimir.murzin@arm.com \
    --cc=xu.panda668@gmail.com \
    --cc=xu.panda@zte.com.cn \
    --cc=zealci@zte.com.cn \
    /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