From: Jan Kara Date: Tue, 19 Jun 2018 03:19:55 +0000 (-0400) Subject: libext2fs: fix overflow when checking s_inodes_count in ext2fs_open() X-Git-Tag: v1.44.3-rc1~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85f1c93dd284c425d6c5423c7bbb1b709b0c00c4;p=thirdparty%2Fe2fsprogs.git libext2fs: fix overflow when checking s_inodes_count in ext2fs_open() The check whether s_inodes_count is correct in ext2fs_open() can overflow and thus not catch all problematic cases. Fix the test. Reviewed-by: Andreas Dilger Signed-off-by: Jan Kara Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index 21729574f..93d41b335 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -380,7 +380,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, goto cleanup; } fs->group_desc_count = groups_cnt; - if (fs->group_desc_count * EXT2_INODES_PER_GROUP(fs->super) != + if ((__u64)fs->group_desc_count * EXT2_INODES_PER_GROUP(fs->super) != fs->super->s_inodes_count) { retval = EXT2_ET_CORRUPT_SUPERBLOCK; goto cleanup;