btrfs-progs: fix name lengths in cmd_subvol_create
authorEric Sandeen <sandeen@redhat.com>
Fri, 25 Jan 2013 19:27:46 +0000 (13:27 -0600)
committerZach Brown <zab@redhat.com>
Wed, 6 Feb 2013 00:09:41 +0000 (16:09 -0800)
cmd_subvol_create() calls either BTRFS_IOC_SUBVOL_CREATE
or BTRFS_IOC_SUBVOL_CREATE_V2 depending on whether or
not inherit is set.  However, these 2 ioctls have different
args structures with different length name[] members.

In the BTRFS_IOC_SUBVOL_CREATE case, the arg is
btrfs_ioctl_vol_args, with a BTRFS_PATH_NAME_MAX length
name, not a BTRFS_SUBVOL_NAME_MAX length name.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
cmds-subvolume.c

index af04a6b..1432b99 100644 (file)
@@ -149,8 +149,8 @@ static int cmd_subvol_create(int argc, char **argv)
                struct btrfs_ioctl_vol_args     args;
 
                memset(&args, 0, sizeof(args));
-               strncpy(args.name, newname, BTRFS_SUBVOL_NAME_MAX);
-               args.name[BTRFS_SUBVOL_NAME_MAX-1] = 0;
+               strncpy(args.name, newname, BTRFS_PATH_NAME_MAX);
+               args.name[BTRFS_PATH_NAME_MAX-1] = 0;
 
                res = ioctl(fddst, BTRFS_IOC_SUBVOL_CREATE, &args);
        }