[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <91B9DC8F-6C6C-4F47-922A-D01DF1079959@redhat.com>
Date: Sat, 09 Nov 2024 06:28:48 -0500
From: Benjamin Coddington <bcodding@...hat.com>
To: Sebastian Feld <sebastian.n.feld@...il.com>
Cc: open list <linux-kernel@...r.kernel.org>,
Linux NFS Mailing List <linux-nfs@...r.kernel.org>
Subject: Re: Kernel strscpy() should be renamed to kstrscpy() Re: [PATCH]
nfs_sysfs_link_rpc_client(): Replace strcpy with strscpy
On 9 Nov 2024, at 6:11, Sebastian Feld wrote:
> On Wed, Nov 6, 2024 at 9:40 PM Benjamin Coddington <bcodding@...hat.com> wrote:
>>
>> On 6 Nov 2024, at 15:20, Roland Mainz wrote:
>>
>>> On Wed, Nov 6, 2024 at 3:49 AM Daniel Yang <danielyangkang@...il.com> wrote:
>>>>
>>>> The function strcpy is deprecated due to lack of bounds checking. The
>>>> recommended replacement is strscpy.
>>>>
>>>> Signed-off-by: Daniel Yang <danielyangkang@...il.com>
>>>> ---
>>>> fs/nfs/sysfs.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c
>>>> index bf378ecd5..f3d0b2ef9 100644
>>>> --- a/fs/nfs/sysfs.c
>>>> +++ b/fs/nfs/sysfs.c
>>>> @@ -280,7 +280,7 @@ void nfs_sysfs_link_rpc_client(struct nfs_server *server,
>>>> char name[RPC_CLIENT_NAME_SIZE];
>>>> int ret;
>>>>
>>>> - strcpy(name, clnt->cl_program->name);
>>>> + strscpy(name, clnt->cl_program->name);
>>>
>>> How should the "bounds checking" work in this case if you only pass
>>> two arguments ?
>>
>> The linux kernel strscpy() checks the sizeof the destination.
>
> Then the kernel strscpy() should be renamed accordingly, and not
> confuse people. Suggested name would be kstrscpy().
> Otherwise this would disqualify strscpy() ever from being adopted as a
> POSIX standard, as there are two - kernel and glibc - conflicting
> implementations
I should have said the linux kernel strscpy() can accept only two args if
the destination is a statically-defined array. Most uses are the three arg
version.
Ben
Powered by blists - more mailing lists