[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9e940637-1381-f51c-afef-9c78d463ace1@fb.com>
Date: Fri, 4 Mar 2022 08:07:21 -0800
From: Yonghong Song <yhs@...com>
To: Yuntao Wang <ytcoode@...il.com>
Cc: andrii@...nel.org, ast@...nel.org, bpf@...r.kernel.org,
daniel@...earbox.net, john.fastabend@...il.com, kafai@...com,
kpsingh@...nel.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, songliubraving@...com
Subject: Re: [PATCH bpf-next v2] bpf: Replace strncpy() with strscpy()
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@...il.com>
Acked-by: Yonghong Song <yhs@...com>
Powered by blists - more mailing lists