summaryrefslogtreecommitdiff
path: root/btrfs-convert.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-03-24 19:19:31 +0100
committerDavid Sterba <dsterba@suse.com>2016-03-30 16:26:38 +0200
commit91b70d4cf1a1aac0ed0a9e810e0499e91244e7fd (patch)
tree261e7d95c2336ef9158dddf677f199fca6eb8029 /btrfs-convert.c
parent41f6ae4820b7c288a6688086bd1a61687a50e3f3 (diff)
btrfs-progs: use safe copy for label buffer everywhere
There's a mix of opencoded strncpy + null termination, strncpy, memcppy without termination etc. Unify them and use the helper. Resolves-coverity-id: 1357105 Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'btrfs-convert.c')
-rw-r--r--btrfs-convert.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/btrfs-convert.c b/btrfs-convert.c
index 1768e4e9..4474489b 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -2600,8 +2600,8 @@ static int do_convert(const char *devname, int datacsum, int packing, int noxatt
}
memset(root->fs_info->super_copy->label, 0, BTRFS_LABEL_SIZE);
if (copylabel == 1) {
- strncpy(root->fs_info->super_copy->label,
- cctx.volume_name, BTRFS_LABEL_SIZE);
+ __strncpy_null(root->fs_info->super_copy->label,
+ cctx.volume_name, BTRFS_LABEL_SIZE - 1);
fprintf(stderr, "copy label '%s'\n",
root->fs_info->super_copy->label);
} else if (copylabel == -1) {
@@ -3116,8 +3116,7 @@ int main(int argc, char *argv[])
"WARNING: label too long, trimmed to %d bytes\n",
BTRFS_LABEL_SIZE - 1);
}
- strncpy(fslabel, optarg, BTRFS_LABEL_SIZE - 1);
- fslabel[BTRFS_LABEL_SIZE - 1] = 0;
+ __strncpy_null(fslabel, optarg, BTRFS_LABEL_SIZE - 1);
break;
case 'L':
copylabel = 1;