diff --git a/common/filesystem-utils.c b/common/filesystem-utils.c index 66269ad9..8dee27aa 100644 --- a/common/filesystem-utils.c +++ b/common/filesystem-utils.c @@ -102,7 +102,7 @@ static int set_label_unmounted(const char *dev, const char *label) error_msg(ERROR_MSG_START_TRANS, "set label"); return PTR_ERR(trans); } - __strncpy_null(root->fs_info->super_copy->label, label, BTRFS_LABEL_SIZE - 1); + __strncpy_null(root->fs_info->super_copy->label, label, BTRFS_LABEL_SIZE); btrfs_commit_transaction(trans, root); @@ -123,7 +123,7 @@ static int set_label_mounted(const char *mount_path, const char *labelp) } memset(label, 0, sizeof(label)); - __strncpy_null(label, labelp, BTRFS_LABEL_SIZE - 1); + __strncpy_null(label, labelp, BTRFS_LABEL_SIZE); if (ioctl(fd, BTRFS_IOC_SET_FSLABEL, label) < 0) { error("unable to set label of %s: %m", mount_path); close(fd); @@ -153,7 +153,7 @@ int get_label_unmounted(const char *dev, char *label) return -1; __strncpy_null(label, root->fs_info->super_copy->label, - BTRFS_LABEL_SIZE - 1); + BTRFS_LABEL_SIZE); /* Now we close it since we are done. */ close_ctree(root); @@ -187,7 +187,7 @@ int get_label_mounted(const char *mount_path, char *labelp) return ret; } - __strncpy_null(labelp, label, BTRFS_LABEL_SIZE - 1); + __strncpy_null(labelp, label, BTRFS_LABEL_SIZE); close(fd); return 0; } diff --git a/convert/common.c b/convert/common.c index 508697e2..d0d3e087 100644 --- a/convert/common.c +++ b/convert/common.c @@ -148,7 +148,7 @@ static int setup_temp_super(int fd, struct btrfs_mkfs_config *cfg, btrfs_set_super_cache_generation(&super, -1); btrfs_set_super_incompat_flags(&super, cfg->features.incompat_flags); if (cfg->label) - __strncpy_null(super.label, cfg->label, BTRFS_LABEL_SIZE - 1); + __strncpy_null(super.label, cfg->label, BTRFS_LABEL_SIZE); /* Sys chunk array will be re-initialized at chunk tree init time */ super.sys_chunk_array_size = 0; diff --git a/convert/main.c b/convert/main.c index 139fc15b..3d2fd61a 100644 --- a/convert/main.c +++ b/convert/main.c @@ -1323,7 +1323,7 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize, memset(root->fs_info->super_copy->label, 0, BTRFS_LABEL_SIZE); if (convert_flags & CONVERT_FLAG_COPY_LABEL) { __strncpy_null(root->fs_info->super_copy->label, - cctx.label, BTRFS_LABEL_SIZE - 1); + cctx.label, BTRFS_LABEL_SIZE); printf("Copy label '%s'\n", root->fs_info->super_copy->label); } else if (convert_flags & CONVERT_FLAG_SET_LABEL) { strcpy(root->fs_info->super_copy->label, fslabel); @@ -1938,7 +1938,7 @@ int BOX_MAIN(convert)(int argc, char *argv[]) "label too long, trimmed to %d bytes", BTRFS_LABEL_SIZE - 1); } - __strncpy_null(fslabel, optarg, BTRFS_LABEL_SIZE - 1); + __strncpy_null(fslabel, optarg, BTRFS_LABEL_SIZE); break; case 'L': copylabel = CONVERT_FLAG_COPY_LABEL; diff --git a/mkfs/common.c b/mkfs/common.c index ec3b25b8..ee0284bf 100644 --- a/mkfs/common.c +++ b/mkfs/common.c @@ -476,7 +476,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg) btrfs_set_super_nr_global_roots(&super, 1); if (cfg->label) - __strncpy_null(super.label, cfg->label, BTRFS_LABEL_SIZE - 1); + __strncpy_null(super.label, cfg->label, BTRFS_LABEL_SIZE); /* create the tree of root objects */ memset(buf->data, 0, cfg->nodesize);