btrfs_ioctl_vol_args vol_args;
memset(&vol_args, 0, sizeof(vol_args));
vol_args.fd = 0;
- strncpy(vol_args.name, name.c_str(), sizeof(vol_args.name));
+ strncpy(vol_args.name, name.c_str(), sizeof(vol_args.name) - 1);
+ vol_args.name[sizeof(vol_args.name) - 1] = '\0';
int ret = ::ioctl(get_basedir_fd(), BTRFS_IOC_SNAP_DESTROY, &vol_args);
if (ret) {