ChangeLog, read_bb.c:
Make ext2fs_read_bb_inode more robust against a completely trashed bad
block inode.
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index b8675fa..ccb74d4 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,8 @@
+1998-06-16 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * read_bb.c (ext2fs_read_bb_inode): Make function more robust
+ against a completely trashed bad block inode.
+
1998-06-10 Theodore Ts'o <tytso@rsts-11.mit.edu>
* alloc_tables.c (ext2fs_allocate_group_table): Fix bug so that if
diff --git a/lib/ext2fs/read_bb.c b/lib/ext2fs/read_bb.c
index c005d42..85c8613 100644
--- a/lib/ext2fs/read_bb.c
+++ b/lib/ext2fs/read_bb.c
@@ -51,6 +51,10 @@
if (blockcnt < 0)
return 0;
+ if ((*block_nr < fs->super->s_first_data_block) ||
+ (*block_nr >= fs->super->s_blocks_count))
+ return 0; /* Ignore illegal blocks */
+
rb->err = ext2fs_badblocks_list_add(rb->bb_list, *block_nr);
if (rb->err)
return BLOCK_ABORT;
@@ -73,7 +77,11 @@
retval = ext2fs_read_inode(fs, EXT2_BAD_INO, &inode);
if (retval)
return retval;
- numblocks = (inode.i_blocks / (fs->blocksize / 512)) + 20;
+ if (inode.i_blocks < 500)
+ numblocks = (inode.i_blocks /
+ (fs->blocksize / 512)) + 20;
+ else
+ numblocks = 500;
retval = ext2fs_badblocks_list_create(bb_list, numblocks);
if (retval)
return retval;