aboutsummaryrefslogtreecommitdiff
path: root/lib/ext2fs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ext2fs/inode.c')
-rw-r--r--lib/ext2fs/inode.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
index 75df418d..6f42882e 100644
--- a/lib/ext2fs/inode.c
+++ b/lib/ext2fs/inode.c
@@ -144,6 +144,8 @@ errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks,
errcode_t (*save_get_blocks)(ext2_filsys f, ext2_ino_t ino, blk_t *blocks);
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
+ if (fs->blocksize < 1024)
+ return EXT2_FILSYS_CORRUPTED; /* Should never happen */
/*
* If fs->badblocks isn't set, then set it --- since the inode
@@ -309,6 +311,7 @@ errcode_t ext2fs_inode_scan_goto_blockgroup(ext2_inode_scan scan,
{
scan->current_group = group - 1;
scan->groups_left = scan->fs->group_desc_count - group;
+ scan->bad_block_ptr = 0;
return get_next_blockgroup(scan);
}
@@ -332,6 +335,12 @@ static errcode_t check_for_inode_bad_blocks(ext2_inode_scan scan,
if (blk == 0)
return 0;
+ /* Make sure bad_block_ptr is still valid */
+ if (scan->bad_block_ptr >= bb->num) {
+ scan->scan_flags &= ~EXT2_SF_CHK_BADBLOCKS;
+ return 0;
+ }
+
/*
* If the current block is greater than the bad block listed
* in the bad block list, then advance the pointer until this
@@ -757,6 +766,8 @@ errcode_t ext2fs_read_inode2(ext2_filsys fs, ext2_ino_t ino,
int cache_slot, fail_csum;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
+ if (fs->blocksize < 1024)
+ return EXT2_FILSYS_CORRUPTED; /* Should never happen */
/* Check to see if user has an override function */
if (fs->read_inode &&