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

From: Mark Harmstone
Date: Fri Jun 20 2025 - 01:15:55 EST


On 20/06/2025 2.43 am, Brahmajit Das wrote:
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -215,7 +215,7 @@ void btrfs_describe_block_groups(u64 bg_flags, char *buf, u32 size_buf)
u32 size_bp = size_buf;
if (!flags) {
- strcpy(bp, "NONE");
+ memcpy(bp, "NONE", 5);
return;
}

There's still the problem here that you're hardcoding a magic number,
and that memcpy is no safer than strcpy.

If your aim is to get rid of strcpy entirely in the codebase, this is
more than likely impossible.