aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ioctl.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2012-04-26 12:36:56 -0400
committerJosef Bacik <josef@redhat.com>2012-05-30 10:23:31 -0400
commita27202fbe92b12eec895c36644440175de01d7a6 (patch)
tree90e3dfc70f43afe69e1e8f11ad5be08549a0e614 /fs/btrfs/ioctl.c
parentf07c9a79f06cd33b1c9c2c4eacb60bafa7e3f310 (diff)
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: Jim Meyering <meyering@redhat.com>
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r--fs/btrfs/ioctl.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 9ebb2c7145ad..3d8ab27622cd 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2263,10 +2263,12 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg)
2263 di_args->bytes_used = dev->bytes_used; 2263 di_args->bytes_used = dev->bytes_used;
2264 di_args->total_bytes = dev->total_bytes; 2264 di_args->total_bytes = dev->total_bytes;
2265 memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid)); 2265 memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid));
2266 if (dev->name) 2266 if (dev->name) {
2267 strncpy(di_args->path, dev->name, sizeof(di_args->path)); 2267 strncpy(di_args->path, dev->name, sizeof(di_args->path));
2268 else 2268 di_args->path[sizeof(di_args->path) - 1] = 0;
2269 } else {
2269 di_args->path[0] = '\0'; 2270 di_args->path[0] = '\0';
2271 }
2270 2272
2271out: 2273out:
2272 if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args))) 2274 if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args)))