From 91b70d4cf1a1aac0ed0a9e810e0499e91244e7fd Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 24 Mar 2016 19:19:31 +0100 Subject: 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 --- btrfs-convert.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'btrfs-convert.c') 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; -- cgit v1.2.3