From: Eric Sandeen Date: Fri, 20 Jul 2007 21:50:26 +0000 (-0500) Subject: Fix test in ext2fs_check_desc() for inode table within block group X-Git-Tag: v1.40.3~35 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=bd828a27e2cfec9f14837d9a693e2a414f44bf91;p=tools%2Fe2fsprogs.git 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. You can create (valid) filesystems that will cause e2fsck to complain via one of the following mkfs commands: mkfs.ext3 -F -b 1024 /dev/sdb1 2046000000 mke2fs -j -F -b 4096 -m 0 -N 5217280 /mnt/test/fsfile2 327680 mkfs.ext2 -F -b 1024 -m 0 -g 256 -N 3744 fsfile 1024 Addresses-Red-Hat-Bugzilla: #214765 Signed-off-by: Eric Sandeen Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/check_desc.c b/lib/ext2fs/check_desc.c index 3150d3e..146f9e5 100644 --- a/lib/ext2fs/check_desc.c +++ b/lib/ext2fs/check_desc.c @@ -61,7 +61,7 @@ errcode_t ext2fs_check_desc(ext2_filsys fs) */ 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; diff --git a/tests/f_full_bg/expect.1 b/tests/f_full_bg/expect.1 new file mode 100644 index 0000000..00819bf --- /dev/null +++ b/tests/f_full_bg/expect.1 @@ -0,0 +1,7 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +test_filesys: 11/3744 files (9.1% non-contiguous), 685/769 blocks +Exit status is 0 diff --git a/tests/f_full_bg/expect.2 b/tests/f_full_bg/expect.2 new file mode 100644 index 0000000..00819bf --- /dev/null +++ b/tests/f_full_bg/expect.2 @@ -0,0 +1,7 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +test_filesys: 11/3744 files (9.1% non-contiguous), 685/769 blocks +Exit status is 0 diff --git a/tests/f_full_bg/image.gz b/tests/f_full_bg/image.gz new file mode 100644 index 0000000..9be419d Binary files /dev/null and b/tests/f_full_bg/image.gz differ diff --git a/tests/f_full_bg/name b/tests/f_full_bg/name new file mode 100644 index 0000000..b0614de --- /dev/null +++ b/tests/f_full_bg/name @@ -0,0 +1 @@ +inode table in last block of first bg