btrfs-progs: Fix malloc size for superblock.

recover_prepare() in chunk-recover.c alloc memory which only contains
sizeof(struct btrfs_super_block). This will cause glibc malloc error
after superblock csum is calculated.

Use BTRFS_SUPER_INFO_SIZE to fix the bug.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
Qu Wenruo 2014-07-03 17:36:38 +08:00 committed by David Sterba
parent 5a7157e1a6
commit a1a3dc7fd4
1 changed files with 1 additions and 1 deletions

View File

@ -1340,7 +1340,7 @@ static int recover_prepare(struct recover_control *rc, char *path)
return -1;
}
sb = malloc(sizeof(struct btrfs_super_block));
sb = malloc(BTRFS_SUPER_INFO_SIZE);
if (!sb) {
fprintf(stderr, "allocating memory for sb failed.\n");
ret = -ENOMEM;