summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-06-12 14:36:51 +0200
committerDavid Sterba <dsterba@suse.cz>2015-06-12 16:44:48 +0200
commit6a039e5063fc96cc72a0a0b2bdc97403fb080de1 (patch)
tree162acdd186f1c1bbdba875ebf470f33a67f691e1 /utils.c
parent2e151027d245a762326dac8e814db9fc59113454 (diff)
downloadbtrfs-progs-6a039e5063fc96cc72a0a0b2bdc97403fb080de1.tar.gz
btrfs-progs: properly set up ioctl arguments
At some places we do not clear the whole ioctl structure and could pass garbage to kernel. Zero the ioctl vol_args and use a helper for copying the path. Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/utils.c b/utils.c
index 087f371..591b2a1 100644
--- a/utils.c
+++ b/utils.c
@@ -1409,8 +1409,8 @@ int btrfs_register_one_device(const char *fname)
strerror(errno));
return -errno;
}
- strncpy(args.name, fname, BTRFS_PATH_NAME_MAX);
- args.name[BTRFS_PATH_NAME_MAX-1] = 0;
+ memset(&args, 0, sizeof(args));
+ strncpy_null(args.name, fname);
ret = ioctl(fd, BTRFS_IOC_SCAN_DEV, &args);
e = errno;
if (ret < 0) {