From a7843581f5c862db79286c7e73f5ca76d59dccea Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 19 Jan 2009 23:09:37 -0500 Subject: [PATCH] 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" --- lib/ext2fs/inode.c | 2 ++ 1 file changed, 2 insertions(+) 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); -- 1.8.3.1