aboutsummaryrefslogtreecommitdiffstats
path: root/e2fsck/pass1b.c
diff options
context:
space:
mode:
authorEric Sandeen <esandeen@redhat.com>2006-09-12 14:55:22 -0400
committerTheodore Ts'o <tytso@mit.edu>2006-09-12 14:55:22 -0400
commitbb1a46a430a99f73ddaf7cf74e380dd5cf36382f (patch)
treef953b23a073c1d0c3f248d22895b88adebe096d0 /e2fsck/pass1b.c
parent9a85c2ab3b7daa602de6e0e70fe18fe0c8044ee3 (diff)
downloadandroid_external_e2fsprogs-bb1a46a430a99f73ddaf7cf74e380dd5cf36382f.tar.gz
android_external_e2fsprogs-bb1a46a430a99f73ddaf7cf74e380dd5cf36382f.tar.bz2
android_external_e2fsprogs-bb1a46a430a99f73ddaf7cf74e380dd5cf36382f.zip
Fix loops over group descriptors to prevent 2**32-1 block number overflows
For loops iterating over all group descriptors, consistently define first_block and last_block in a way that they are inclusive of the range, and do not overflow. Previously on the last block group we did a test of <= first + dec_blocks; this would actually wrap back to 0 for a total block count of 2^32-1 Also add handling of last block group which may be smaller. Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Diffstat (limited to 'e2fsck/pass1b.c')
-rw-r--r--e2fsck/pass1b.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/e2fsck/pass1b.c b/e2fsck/pass1b.c
index a9640ffa..cec60cf4 100644
--- a/e2fsck/pass1b.c
+++ b/e2fsck/pass1b.c
@@ -779,16 +779,16 @@ errout:
static int check_if_fs_block(e2fsck_t ctx, blk_t test_block)
{
ext2_filsys fs = ctx->fs;
- blk_t block;
+ blk_t first_block;
dgrp_t i;
- block = fs->super->s_first_data_block;
+ first_block = fs->super->s_first_data_block;
for (i = 0; i < fs->group_desc_count; i++) {
- /* Check superblocks/block group descriptros */
+ /* Check superblocks/block group descriptors */
if (ext2fs_bg_has_super(fs, i)) {
- if (test_block >= block &&
- (test_block <= block + fs->desc_blocks))
+ if (test_block >= first_block &&
+ (test_block <= first_block + fs->desc_blocks))
return 1;
}
@@ -804,7 +804,7 @@ static int check_if_fs_block(e2fsck_t ctx, blk_t test_block)
(test_block == fs->group_desc[i].bg_inode_bitmap))
return 1;
- block += fs->super->s_blocks_per_group;
+ first_block += fs->super->s_blocks_per_group;
}
return 0;
}