From: Theodore Ts'o Date: Tue, 20 Jan 2009 04:09:37 +0000 (-0500) Subject: ext2fs_read_inode_full: Add safety check to avoid SEGV's on corrupted fs's X-Git-Tag: v1.41.4~21 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=a7843581f5c862db79286c7e73f5ca76d59dccea;p=tools%2Fe2fsprogs.git ext2fs_read_inode_full: Add safety check to avoid SEGV's on corrupted fs's Thanks to Thiemo Nagel for suggesting this. Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c index b3ac9f2..f9cc43c 100644 --- a/lib/ext2fs/inode.c +++ b/lib/ext2fs/inode.c @@ -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);