Fix fencepost error in resize2fs caught by valgrind

There was a off-by-one fencepost error in the logic used to check if
we avoid copying zero-filled blocks when moving an inode table down by
a block or two.  Thanks to valgrind for catching it.  As far as I know
this fencepost error wasn't causing any actual problems, but it was
definitely a bug.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2005-08-08 18:57:04 -05:00
parent b28a6e96af
commit 2787276ec5
2 changed files with 15 additions and 1 deletions

View File

@ -1,3 +1,12 @@
2005-08-08 Theodore Ts'o <tytso@mit.edu>
* resize2fs.c (move_itables): Fix fencepost error caught by valgrind.
(adjust_superblock): Clear the newly allocated descriptor
blocks when we allocate them to avoid false positives from
valgrind (and so that the unusued descriptors at the tail
end of the newly allocated descriptor blocks are zero'ed
out, include of random garbage).
2006-06-30 Theodore Ts'o <tytso@mit.edu>
* Release of E2fsprogs 1.38

View File

@ -281,6 +281,11 @@ retry:
&fs->group_desc);
if (retval)
goto errout;
if (fs->desc_blocks > rfs->old_fs->desc_blocks)
memset((char *) fs->group_desc +
(rfs->old_fs->desc_blocks * fs->blocksize), 0,
(fs->desc_blocks - rfs->old_fs->desc_blocks) *
fs->blocksize);
}
/*
@ -1379,7 +1384,7 @@ static errcode_t move_itables(ext2_resize_t rfs)
* things by not rewriting blocks that we know to be zero
* already.
*/
for (cp = rfs->itable_buf+size, n=0; n < size; n++, cp--)
for (cp = rfs->itable_buf+size-1, n=0; n < size; n++, cp--)
if (*cp)
break;
n = n >> EXT2_BLOCK_SIZE_BITS(fs->super);