From 6723bc76fc728a1d5a55661890d8b1f8a8edc9ab Mon Sep 17 00:00:00 2001 From: Bowei Zhuang Date: Wed, 10 May 2023 11:39:33 +0800 Subject: [PATCH] [bugfix] corrected rec_len mistake in expand_dir Signed-off-by: Bowei Zhuang --- lib/ext2fs/expanddir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ext2fs/expanddir.c b/lib/ext2fs/expanddir.c index 3481fbbd8..68b59a8bf 100644 --- a/lib/ext2fs/expanddir.c +++ b/lib/ext2fs/expanddir.c @@ -154,7 +154,7 @@ static errcode_t make_indexed_dir(ext2_filsys fs, ext2_ino_t dir, struct ext2_in root = (struct ext2_dx_root *) (dx_info.frames[0].buf); fde = &(root->dotdot); de = (struct ext2_dir_entry_2 *) ((char *) fde + get_rec_len(fs, fde->rec_len)); - if ((char *) de >= (((char *) root) + blocksize)) + if ((char *) de > (((char *) root) + blocksize - csum_size)) return EXT2_FILSYS_CORRUPTED; len = ((char *) root) + (blocksize - csum_size) - (char *) de; data2 = dx_info.frames[1].buf; @@ -269,4 +269,4 @@ errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir) { return make_indexed_dir(fs, dir, &inode); return ext2fs_expand_dir2(fs, dir); -} \ No newline at end of file +}