btrfs-progs: dump-super: print chunks after validation
authorDavid Sterba <dsterba@suse.com>
Tue, 4 Oct 2016 16:12:30 +0000 (18:12 +0200)
committerDavid Sterba <dsterba@suse.com>
Wed, 5 Oct 2016 10:39:01 +0000 (12:39 +0200)
The fuzz test 005-simple-dump-super hits a crash, because we print the
chunks too early.

Signed-off-by: David Sterba <dsterba@suse.com>
cmds-inspect-dump-super.c

index 8eb3189..d9f7bfb 100644 (file)
@@ -100,7 +100,6 @@ static void print_sys_chunk_array(struct btrfs_super_block *sb)
                        if (cur_offset + len > array_size)
                                goto out_short_read;
 
-                       print_chunk(buf, chunk);
                        num_stripes = btrfs_chunk_num_stripes(buf, chunk);
                        if (!num_stripes) {
                                error(
@@ -111,6 +110,7 @@ static void print_sys_chunk_array(struct btrfs_super_block *sb)
                        len = btrfs_chunk_item_size(num_stripes);
                        if (cur_offset + len > array_size)
                                goto out_short_read;
+                       print_chunk(buf, chunk);
                } else {
                        error("unexpected item type %u in sys_array at offset %u",
                                (u32)key.type, cur_offset);