Skip to contentSkip to conversation

fix test in ext2fs_check_desc() for inode table within block group

PATCH In review Eric Sandeen 2 participants 3 messages Jul 20, 2007 – Jul 22, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix test in ext2fs_check_desc() for inode table within block group

The test in ext2fs_check_desc() is off by one; if the inode table goes all the way to the last block of the block group, it will falsely assert that it has extended past it. The last block of a range is start + len -1, not start + len.

Testcase to follow.

lib/ext2fs/check_desc.c +1 -1
Index: e2fsprogs-1.40.2/lib/ext2fs/check_desc.c
===================================================================
@@ -61,7 +61,7 @@ errcode_t ext2fs_check_desc(ext2_filsys 
 		 */
 		if (fs->group_desc[i].bg_inode_table < first_block ||
 		    ((fs->group_desc[i].bg_inode_table +
-		      fs->inode_blocks_per_group) > last_block))
+		      fs->inode_blocks_per_group - 1) > last_block))
 			return EXT2_ET_GDESC_BAD_INODE_TABLE;
 	}
 	return 0;
#1 lore raw
Quoted 5 lines · Eric Sandeen

The test in ext2fs_check_desc() is off by one; if the inode table goes all the way to the last block of the block group, it will falsely assert that it has extended past it. The last block of a range is start + len -1, not start + len.

(btw the kernel has this same problem, so it's not mountable either - will send that patch Monday)

-Eric

#2 lore raw
In reply to Eric Sandeen
Quoted 4 lines · Eric Sandeen

The test in ext2fs_check_desc() is off by one; if the inode table goes all the way to the last block of the block group, it will falsely assert that it has extended past it. The last block of a range is start + len -1, not start + len.

Thanks, committed into git (combined with the test case) and updated commit log to include the Red Hat Bugzilla number.

- Ted