lkml.org 
[lkml]   [2022]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH linux-next] kernfs: use strscpy() is more robust and safer
On Tue, Nov 15, 2022 at 08:47:45AM +0800, guo.ziliang@zte.com.cn wrote:
> From: guo ziliang <guo.ziliang@zte.com.cn>
>
> The implementation of strscpy() is more robust and safer.

How exactly is it more robust and safer?

> That's now the recommended way to copy NUL terminated strings.

Recommended by whom for what?



>
> Signed-off-by: guo ziliang <guo.ziliang@zte.com.cn>
> ---
> fs/kernfs/dir.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index 77d7a3a..fbb8df4 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -844,7 +844,7 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent,
>
> spin_lock_irq(&kernfs_pr_cont_lock);
>
> - len = strlcpy(kernfs_pr_cont_buf, path, sizeof(kernfs_pr_cont_buf));
> + len = strscpy(kernfs_pr_cont_buf, path, sizeof(kernfs_pr_cont_buf));

How did you test this change is correct and does not cause any problems?

How was this issue found?

thanks,

greg k-h

\
 
 \ /
  Last update: 2022-11-15 07:43    [W:0.037 / U:1.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site