]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Fix fencepost error in resize2fs caught by valgrind
authorTheodore Ts'o <tytso@mit.edu>
Mon, 8 Aug 2005 23:57:04 +0000 (18:57 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 8 Aug 2005 23:57:04 +0000 (18:57 -0500)
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>
resize/ChangeLog
resize/resize2fs.c

index 88dfd9c131322dd75ecda6c6e914c62fa09d483d..b88505e3aab322e241e104f461a666acef8fced5 100644 (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
index fd14c8409f64c06e42d6e4f51b9789f4e44b4688..695bf7b607da257289b1623165c48af3bf0298c4 100644 (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);