Commit 6670d4c2 authored by Xiongfeng Wang's avatar Xiongfeng Wang Committed by David Sterba

btrfs: use correct string length in DEV_INFO ioctl

gcc-8 reports:

fs/btrfs/ioctl.c: In function 'btrfs_ioctl':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
bound 1024 equals destination size [-Wstringop-truncation]

We need one less byte or call strlcpy() to make it a nul-terminated
string. This is done on the next line anyway, but we want to avoid the
warning.
Signed-off-by: default avatarXiongfeng Wang <xiongfeng.wang@linaro.org>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
[ update changelog ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 6f794e3c
...@@ -2798,7 +2798,7 @@ static long btrfs_ioctl_dev_info(struct btrfs_fs_info *fs_info, ...@@ -2798,7 +2798,7 @@ static long btrfs_ioctl_dev_info(struct btrfs_fs_info *fs_info,
struct rcu_string *name; struct rcu_string *name;
name = rcu_dereference(dev->name); name = rcu_dereference(dev->name);
strncpy(di_args->path, name->str, sizeof(di_args->path)); strncpy(di_args->path, name->str, sizeof(di_args->path) - 1);
di_args->path[sizeof(di_args->path) - 1] = 0; di_args->path[sizeof(di_args->path) - 1] = 0;
} else { } else {
di_args->path[0] = '\0'; di_args->path[0] = '\0';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment