summaryrefslogtreecommitdiff
path: root/chunk-recover.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2014-07-03 17:36:38 +0800
committerDavid Sterba <dsterba@suse.cz>2014-10-10 09:09:47 +0200
commita1a3dc7fd4fb7ab0abb1269d030d85e385fc8038 (patch)
treeb28077c47b449257cd58aa41455b71ee042c10bc /chunk-recover.c
parent5a7157e1a6da26c6058ddb889937fcb4f66edee9 (diff)
downloadbtrfs-progs-a1a3dc7fd4fb7ab0abb1269d030d85e385fc8038.tar.gz
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>
Diffstat (limited to 'chunk-recover.c')
-rw-r--r--chunk-recover.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/chunk-recover.c b/chunk-recover.c
index 14c25a7..aa38916 100644
--- a/chunk-recover.c
+++ b/chunk-recover.c
@@ -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;