Skip to content

Commit

Permalink
btrfs: Replace deprecated strncpy() with strscpy_pad()
Browse files Browse the repository at this point in the history
strncpy() is deprecated for NUL-terminated destination buffers. Use
strscpy_pad() instead and don't zero-initialize the param array.

Compile-tested only.

Link: KSPP#90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
  • Loading branch information
toblux authored and intel-lab-lkp committed Feb 25, 2025
1 parent f9d3870 commit 7bf6e1c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/btrfs/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1330,13 +1330,13 @@ MODULE_PARM_DESC(read_policy,

int btrfs_read_policy_to_enum(const char *str, s64 *value_ret)
{
char param[32] = { 0 };
char param[32];
char __maybe_unused *value_str;

if (!str || strlen(str) == 0)
return 0;

strncpy(param, str, sizeof(param) - 1);
strscpy_pad(param, str);

#ifdef CONFIG_BTRFS_EXPERIMENTAL
/* Separate value from input in policy:value format. */
Expand Down

0 comments on commit 7bf6e1c

Please sign in to comment.