Whamcloud - gitweb
Don't crash if s_inode_size is zero
authorTheodore Ts'o <tytso@mit.edu>
Fri, 7 Sep 2007 20:40:25 +0000 (16:40 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 7 Sep 2007 20:40:25 +0000 (16:40 -0400)
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" <tytso@mit.edu>
lib/ext2fs/openfs.c

index 55cc077..1ac1564 100644 (file)
@@ -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) +