From 5308fc1ee5a1e2b402f099fcc0c445387b91a01d Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Wed, 10 Aug 2022 22:43:00 -0400 Subject: [PATCH] libext2fs: validate block # of the inode table in ext2fs_image_inode_write() Signed-off-by: Theodore Ts'o --- lib/ext2fs/imager.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c index b56e0e9ea..6f8582a88 100644 --- a/lib/ext2fs/imager.c +++ b/lib/ext2fs/imager.c @@ -80,6 +80,11 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags) goto errout; } left = fs->inode_blocks_per_group; + if ((blk < fs->super->s_first_data_block) || + (blk + left - 1 >= ext2fs_blocks_count(fs->super))) { + retval = EXT2_ET_GDESC_BAD_INODE_TABLE; + goto errout; + } while (left) { c = BUF_BLOCKS; if (c > left) -- 2.47.3