OSDN Git Service

ChangeLog, read_bb.c:
authorTheodore Ts'o <tytso@mit.edu>
Tue, 16 Jun 1998 05:23:41 +0000 (05:23 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 16 Jun 1998 05:23:41 +0000 (05:23 +0000)
  Make ext2fs_read_bb_inode more robust against a completely trashed bad
  block inode.

lib/ext2fs/ChangeLog
lib/ext2fs/read_bb.c

index b8675fa..ccb74d4 100644 (file)
@@ -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
index c005d42..85c8613 100644 (file)
@@ -51,6 +51,10 @@ static int mark_bad_block(ext2_filsys fs, blk_t *block_nr,
        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 @@ errcode_t ext2fs_read_bb_inode(ext2_filsys fs, ext2_badblocks_list *bb_list)
                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;