From bc507e31ad8a890232dc2b3aec9ee9d68e95622a Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 17 Jun 2008 00:18:58 -0400 Subject: ext2fs_zero_blocks: Avoid clearing more blocks than requested This could cause certain mke2fs feature combinations to result in the initial blocks of the inode table getting wiped out when the journal is created. Signed-off-by: "Theodore Ts'o" --- lib/ext2fs/mkjournal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/ext2fs/mkjournal.c') diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c index ca8e733b..e55dcbda 100644 --- a/lib/ext2fs/mkjournal.c +++ b/lib/ext2fs/mkjournal.c @@ -170,9 +170,11 @@ errcode_t ext2fs_zero_blocks(ext2_filsys fs, blk_t blk, int num, /* OK, do the write loop */ j=0; while (j < num) { - if (blk % STRIDE_LENGTH) + if (blk % STRIDE_LENGTH) { count = STRIDE_LENGTH - (blk % STRIDE_LENGTH); - else { + if (count > (num - j)) + count = num - j; + } else { count = num - j; if (count > STRIDE_LENGTH) count = STRIDE_LENGTH; -- cgit v1.2.3