Skip to content

Commit 2df2c6e

Browse files
tobluxkdave
authored andcommitted
btrfs: replace deprecated strncpy() with strscpy()
strncpy() is deprecated for NUL-terminated destination buffers. Use strscpy() instead and don't zero-initialize the param array. Link: KSPP#90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 5a4041f commit 2df2c6e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/sysfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,13 +1330,13 @@ MODULE_PARM_DESC(read_policy,
13301330

13311331
int btrfs_read_policy_to_enum(const char *str, s64 *value_ret)
13321332
{
1333-
char param[32] = { 0 };
1333+
char param[32];
13341334
char __maybe_unused *value_str;
13351335

13361336
if (!str || strlen(str) == 0)
13371337
return 0;
13381338

1339-
strncpy(param, str, sizeof(param) - 1);
1339+
strscpy(param, str);
13401340

13411341
#ifdef CONFIG_BTRFS_EXPERIMENTAL
13421342
/* Separate value from input in policy:value format. */

0 commit comments

Comments
 (0)