aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2022-08-10 22:43:00 -0400
committerTheodore Ts'o <tytso@mit.edu>2022-08-10 22:43:00 -0400
commit5308fc1ee5a1e2b402f099fcc0c445387b91a01d (patch)
tree0f802e42c017815c0581cf3aa2b0268187a72dff
parent2869485be9b1b94b93a50589de52ca553e5a116d (diff)
downloade2fsprogs-5308fc1ee5a1e2b402f099fcc0c445387b91a01d.tar.gz
libext2fs: validate block # of the inode table in ext2fs_image_inode_write()
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--lib/ext2fs/imager.c5
1 files changed, 5 insertions, 0 deletions
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)