lkml.org 
[lkml]   [2022]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH bpf-next v2] bpf: Replace strncpy() with strscpy()
From


On 3/3/22 11:04 PM, Yuntao Wang wrote:
> Using strncpy() on NUL-terminated strings is considered deprecated[1].
> Moreover, if the length of 'task->comm' is less than the destination buffer
> size, strncpy() will NUL-pad the destination buffer, which is a needless
> performance penalty.
>
> Replacing strncpy() with strscpy() fixes all these issues.
>
> [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
>
> Signed-off-by: Yuntao Wang <ytcoode@gmail.com>

Acked-by: Yonghong Song <yhs@fb.com>

\
 
 \ /
  Last update: 2022-03-04 17:08    [W:0.243 / U:0.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site