From: Theodore Ts'o Date: Fri, 7 Sep 2007 20:40:25 +0000 (-0400) Subject: Don't crash if s_inode_size is zero X-Git-Tag: v1.40.3~26 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=ba9d929d914654f8dba36c634bb537ecf0f0bb04;p=tools%2Fe2fsprogs.git 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" --- diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index 55cc077..1ac1564 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) +