btrfs-progs: Fix malloc size for superblock.
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Thu, 3 Jul 2014 09:36:38 +0000 (17:36 +0800)
committerDavid Sterba <dsterba@suse.cz>
Fri, 10 Oct 2014 07:09:47 +0000 (09:09 +0200)
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>
chunk-recover.c

index 14c25a75492eec599bc8938fc126b76e00d24695..aa38916f76c40d3c83ef2d32a9b604cda2587c1a 100644 (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;