mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2024-12-12 03:13:52 +08:00
ext2fs: fix off-by-one in dx_grow_tree()
There is an off-by-one error in dx_grow_tree() when checking whether we can add another level to the tree. Thus we can grow tree too much leading to possible crashes in the library or corrupted filesystem. Fix the bug. Signed-off-by: Jan Kara <jack@suse.cz> Reviewed-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
cceebf4ece
commit
af7293fe8a
@ -473,7 +473,7 @@ static errcode_t dx_grow_tree(ext2_filsys fs, ext2_ino_t dir,
|
||||
ext2fs_le16_to_cpu(info->frames[i].head->limit))
|
||||
break;
|
||||
/* Need to grow tree depth? */
|
||||
if (i < 0 && info->levels > ext2_dir_htree_level(fs))
|
||||
if (i < 0 && info->levels >= ext2_dir_htree_level(fs))
|
||||
return EXT2_ET_DIR_NO_SPACE;
|
||||
lblk = size / fs->blocksize;
|
||||
size += fs->blocksize;
|
||||
|
Loading…
Reference in New Issue
Block a user