All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rolf Eike Beer <eike-kernel@sf-tec.de>
To: james.bottomley@hansenpartnership.com, yang.yang29@zte.com.cn
Cc: deller@gmx.de, linux-parisc@vger.kernel.org,
	linux-kernel@vger.kernel.org, xu.panda@zte.com.cn,
	yang.yang29@zte.com.cn
Subject: Re: [PATCH linux-next v2] parisc: use strscpy() to instead of strncpy()
Date: Tue, 27 Dec 2022 08:47:05 +0100	[thread overview]
Message-ID: <2298026.kkTNVCUfUN@daneel.sf-tec.de> (raw)
In-Reply-To: <202212261840048448622@zte.com.cn>

[-- Attachment #1: Type: text/plain, Size: 1101 bytes --]

Am Montag, 26. Dezember 2022, 11:40:04 CET schrieb yang.yang29@zte.com.cn:
> 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.
> 
> Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
> Signed-off-by: Yang Yang <yang.yang29@zte.com>
> ---
> change for v2
>  - sizeof(in) is better and simplified, thanks for Helge Deller.
> ---
>  drivers/parisc/pdc_stable.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
> index d6af5726ddf3..d3075445260b 100644
> --- a/drivers/parisc/pdc_stable.c
> +++ b/drivers/parisc/pdc_stable.c
> @@ -274,8 +274,7 @@ pdcspath_hwpath_write(struct pdcspath_entry *entry,
> const char *buf, size_t coun
> 
>  	/* We'll use a local copy of buf */
>  	count = min_t(size_t, count, sizeof(in)-1);
> -	strncpy(in, buf, count);
> -	in[count] = '\0';
> +	strscpy(in, buf, sizeof(in));

What is "count" now needed for? Looks like a write only variable at least in 
these hunks.

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2022-12-27  7:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-26 10:40 [PATCH linux-next v2] parisc: use strscpy() to instead of strncpy() yang.yang29
2022-12-27  7:47 ` Rolf Eike Beer [this message]
2022-12-27 21:30   ` Helge Deller

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=2298026.kkTNVCUfUN@daneel.sf-tec.de \
    --to=eike-kernel@sf-tec.de \
    --cc=deller@gmx.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=xu.panda@zte.com.cn \
    --cc=yang.yang29@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.