Whamcloud - gitweb
ext2fs_read_inode_full: Add safety check to avoid SEGV's on corrupted fs's
authorTheodore Ts'o <tytso@mit.edu>
Tue, 20 Jan 2009 04:09:37 +0000 (23:09 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 20 Jan 2009 04:09:37 +0000 (23:09 -0500)
Thanks to Thiemo Nagel for suggesting this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/inode.c

index b3ac9f2..f9cc43c 100644 (file)
@@ -564,6 +564,8 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
                io = fs->image_io;
        } else {
                group = (ino - 1) / EXT2_INODES_PER_GROUP(fs->super);
+               if (group > fs->group_desc_count)
+                       return EXT2_ET_BAD_INODE_NUM;
                offset = ((ino - 1) % EXT2_INODES_PER_GROUP(fs->super)) *
                        EXT2_INODE_SIZE(fs->super);
                block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super);