btrfs-progs: fix memory leak in btrfs-convert main()
authorByongho Lee <bhlee.kernel@gmail.com>
Thu, 27 Aug 2015 15:38:16 +0000 (00:38 +0900)
committerDavid Sterba <dsterba@suse.com>
Tue, 1 Sep 2015 12:02:48 +0000 (14:02 +0200)
commit9a99d2b683c23cbfb21df0557fa185b36e9e8540
tree04f711e286ec5364f831fa43ecc5656a2b708c51
parent107adbd05d037567d20211732e5c9039853319ed
btrfs-progs: fix memory leak in btrfs-convert main()

In btrfs-convert main(), strdup() allocates memory to fslabel but that
memory is not freed. We could fix it by adding free() calls to every
return point, but that would make the code messy because there are
several return paths.
So I fix it by changing the code using strdup() with local array and
strncpy().

And btrfs-convert main() guarantees that string length of fslabel is not
to exceed 'BTRFS_LABEL_SIZE', so it's enough to use strcpy() instead of
strncpy() to copy fslabel in do_convert().

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
btrfs-convert.c