Commit a27202fb authored by Jim Meyering's avatar Jim Meyering Committed by Josef Bacik

Btrfs: NUL-terminate path buffer in DEV_INFO ioctl result

A device with name of length BTRFS_DEVICE_PATH_NAME_MAX or longer
would not be NUL-terminated in the DEV_INFO ioctl result buffer.
Signed-off-by: default avatarJim Meyering <meyering@redhat.com>
parent f07c9a79
...@@ -2263,10 +2263,12 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) ...@@ -2263,10 +2263,12 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg)
di_args->bytes_used = dev->bytes_used; di_args->bytes_used = dev->bytes_used;
di_args->total_bytes = dev->total_bytes; di_args->total_bytes = dev->total_bytes;
memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid)); memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid));
if (dev->name) if (dev->name) {
strncpy(di_args->path, dev->name, sizeof(di_args->path)); strncpy(di_args->path, dev->name, sizeof(di_args->path));
else di_args->path[sizeof(di_args->path) - 1] = 0;
} else {
di_args->path[0] = '\0'; di_args->path[0] = '\0';
}
out: out:
if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args))) if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args)))
......
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