[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2298026.kkTNVCUfUN@daneel.sf-tec.de>
Date: Tue, 27 Dec 2022 08:47:05 +0100
From: Rolf Eike Beer <eike-kernel@...tec.de>
To: james.bottomley@...senpartnership.com, yang.yang29@....com.cn
Cc: deller@....de, linux-parisc@...r.kernel.org,
linux-kernel@...r.kernel.org, xu.panda@....com.cn,
yang.yang29@....com.cn
Subject: Re: [PATCH linux-next v2] parisc: use strscpy() to instead of strncpy()
Am Montag, 26. Dezember 2022, 11:40:04 CET schrieb yang.yang29@....com.cn:
> From: Xu Panda <xu.panda@....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@....com.cn>
> Signed-off-by: Yang Yang <yang.yang29@....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
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists