From ba9d929d914654f8dba36c634bb537ecf0f0bb04 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 7 Sep 2007 16:40:25 -0400 Subject: [PATCH] Don't crash if s_inode_size is zero Any attempt to open a filesystem with s_inode_size set to zero causes a floating point exception. This is true for e2fsck, dumpe2fs, e2image, etc. Fix ext2fs_open2() so that it returns the error code EXT2_ET_CORRUPT_SUPERBLOCK instead of crashing. Thanks to Dean Bender for reporting this bug. Signed-off-by: "Theodore Ts'o" --- lib/ext2fs/openfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index 55cc07710..1ac1564ad 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -234,6 +234,10 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, retval = EXT2_ET_CORRUPT_SUPERBLOCK; goto cleanup; } + if (EXT2_INODE_SIZE(fs->super) < EXT2_GOOD_OLD_INODE_SIZE) { + retval = EXT2_ET_CORRUPT_SUPERBLOCK; + goto cleanup; + } fs->fragsize = EXT2_FRAG_SIZE(fs->super); fs->inode_blocks_per_group = ((fs->super->s_inodes_per_group * EXT2_INODE_SIZE(fs->super) + -- 2.47.2