]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: fix off-by-one bounds check on group number
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 25 Jul 2014 02:19:27 +0000 (22:19 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 25 Jul 2014 02:19:27 +0000 (22:19 -0400)
Since fs->group_desc_count is the number of block groups, the number
of the last group is always one less than this count.  Fix the bounds
check to reflect that.

This flaw shouldn't have any user-visible side effects, since the
block bitmap test based on last_grp later on can handle overbig block
numbers.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass1.c

index 7a887de14ba2362f03919beb2d753bc75ccaca61..cf36a086a373de91738d1bfcee91105b6a9c1a1c 100644 (file)
@@ -2653,8 +2653,8 @@ static void new_table_block(e2fsck_t ctx, blk64_t first_block, dgrp_t group,
                first_block = ext2fs_group_first_block2(fs,
                                                        flexbg_size * flexbg);
                last_grp = group | (flexbg_size - 1);
-               if (last_grp > fs->group_desc_count)
-                       last_grp = fs->group_desc_count;
+               if (last_grp >= fs->group_desc_count)
+                       last_grp = fs->group_desc_count - 1;
                last_block = ext2fs_group_last_block2(fs, last_grp);
        } else
                last_block = ext2fs_group_last_block2(fs, group);