Skip to contentSkip to conversation

Btrfs-progs: fix segfault in fsck if the chunk tree is bogus

PATCH New Josef Bacik 1 participant 1 message Mar 28, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs-progs: fix segfault in fsck if the chunk tree is bogus

I made open_ctree fail if the chunk tree couldn't be open, which means that fsck now segfaults if it can't open the chunk tree. So fix fsck to check the fs_info we get back from open_ctree_fsinfo to make sure it's valid and exit if it's not instead of segfaulting. Thanks,

---
 cmds-check.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
cmds-check.c +5 -0
index 35e9177..eef959e 100644
@@ -3642,6 +3642,11 @@ int cmd_check(int argc, char **argv)
 	}
 
 	info = open_ctree_fs_info(argv[optind], bytenr, rw, 1);
+	if (!info) {
+		fprintf(stderr, "Couldn't open file system\n");
+		return -EIO;
+	}
+
 	uuid_unparse(info->super_copy.fsid, uuidbuf);
 	printf("Checking filesystem on %s\nUUID: %s\n", argv[optind], uuidbuf);
 
Signature · 1 line
1.7.7.6