Blame SOURCES/e2fsprogs-1.42.9-14-e2fsck-fix-off-by-one-bounds-check-on-group-number.patch

98901c
From 2ab3543e3b3330317769adcbe4bdb2f3c0b855e9 Mon Sep 17 00:00:00 2001
98901c
From: "Darrick J. Wong" <darrick.wong@oracle.com>
98901c
Date: Thu, 24 Jul 2014 22:19:27 -0400
98901c
Subject: [PATCH 14/16] e2fsck: fix off-by-one bounds check on group number
98901c
98901c
commit b4f724c8a90987d4785fd1accfe69c125567be39
98901c
98901c
Since fs->group_desc_count is the number of block groups, the number
98901c
of the last group is always one less than this count.  Fix the bounds
98901c
check to reflect that.
98901c
98901c
This flaw shouldn't have any user-visible side effects, since the
98901c
block bitmap test based on last_grp later on can handle overbig block
98901c
numbers.
98901c
98901c
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
98901c
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
98901c
---
98901c
 e2fsck/pass1.c | 4 ++--
98901c
 1 file changed, 2 insertions(+), 2 deletions(-)
98901c
98901c
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
98901c
index 71b3000a..b58a0ca7 100644
98901c
--- a/e2fsck/pass1.c
98901c
+++ b/e2fsck/pass1.c
98901c
@@ -2599,8 +2599,8 @@ static void new_table_block(e2fsck_t ctx, blk64_t first_block, dgrp_t group,
98901c
 		first_block = ext2fs_group_first_block2(fs,
98901c
 							flexbg_size * flexbg);
98901c
 		last_grp = group | (flexbg_size - 1);
98901c
-		if (last_grp > fs->group_desc_count)
98901c
-			last_grp = fs->group_desc_count;
98901c
+		if (last_grp >= fs->group_desc_count)
98901c
+			last_grp = fs->group_desc_count - 1;
98901c
 		last_block = ext2fs_group_last_block2(fs, last_grp);
98901c
 	} else
98901c
 		last_block = ext2fs_group_last_block2(fs, group);
98901c
-- 
98901c
2.20.1
98901c