Re: [PATCH v4] btrfs: replace deprecated strcpy with strscpy

From: David Sterba
Date: Tue Jul 01 2025 - 11:03:07 EST


On Fri, Jun 20, 2025 at 10:19:57PM +0530, Brahmajit Das wrote:
> strcpy is deprecated due to lack of bounds checking. This patch replaces
> strcpy with strscpy, the recommended alternative for null terminated
> strings, to follow best practices.
>
> There are instances where strscpy cannot be used such as where both the
> source and destination are character pointers. In that instance we can
> use sysfs_emit.
>
> Link: https://github.com/KSPP/linux/issues/88
> Suggested-by: Anthony Iliopoulos <ailiop@xxxxxxxx>
> Suggested-by: David Sterba <dsterba@xxxxxxx>
> Signed-off-by: Brahmajit Das <bdas@xxxxxxx>
> ---
>
> Changes in v2: using sysfs_emit instead of scnprintf.
> Changes in v3: Removed string.h in xattr, since we are not using any.
> fucntions from string.h and fixed length in memcpy in volumes.c
> Changes in v4: As suggested by David, moving "NONE" as initial value of
> buf in describe_relocation() and removed copying of "NONE" to bp in
> btrfs_describe_block_groups().

Sorry for the delay, added to for-next. Thanks.