btrfs-progs: init uninitialized output buf for btrfs-restore
authorGui Hecheng <guihc.fnst@cn.fujitsu.com>
Thu, 21 Aug 2014 03:35:36 +0000 (11:35 +0800)
committerDavid Sterba <dsterba@suse.cz>
Sun, 14 Sep 2014 11:10:44 +0000 (13:10 +0200)
commit2527730d5d7e34b7848d8a49b47830e91adb10a1
tree9bad7b92a89eefa3dd802fa4e770450daafe7c32
parent90a379a876192ad0aca1ee81332f055886f8a5e8
btrfs-progs: init uninitialized output buf for btrfs-restore

A memory problem reported by valgrind as follows:
=== Syscall param pwrite64(buf) points to uninitialised byte(s)
When running:
# valgrind --leak-check=yes btrfs restore /dev/sda9 /mnt/backup

Because the output buf size is alloced with malloc, but the length of
output data is shorter than the sizeof(buf), so valgrind report
uninitialised byte(s).
We could use calloc to repalce malloc and clear this WARNING away.

Reported-by: Marc Dietrich <marvin24@gmx.de>
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
cmds-restore.c