]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: reset the size of the zeroing buffer
authorAdrien Schildknecht <adriens@google.com>
Wed, 10 Aug 2016 20:43:25 +0000 (16:43 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 10 Aug 2016 20:43:25 +0000 (16:43 -0400)
When a ext2_filsys is freed, ext2fs_zero_blocks2() frees the buffer but
does not reset its size.
If this function is later called with a new ext2_filsys, the code
assumes that the buffer is still valid and return a NULL pointer.

Valgrind output:
==188948== Syscall param pwrite64(buf) points to unaddressable byte(s)
==188948==    at 0x4E46D03: __pwrite_nocancel (syscall-template.S:81)
==188948==    by 0x1254EC: raw_write_blk (unix_io.c:240)
==188948==    by 0x124AAB: unix_write_blk64 (unix_io.c:850)
==188948==    by 0x122893: ext2fs_zero_blocks2 (mkjournal.c:204)

Signed-off-by: Adrien Schildknecht <adriens@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/mkjournal.c

index af983c72fd3ca3697c165aa244c22d7692afa339..43ffa53ff05fc532bb96ee9a859ba36ab76a2fee 100644 (file)
@@ -162,6 +162,7 @@ errcode_t ext2fs_zero_blocks2(ext2_filsys fs, blk64_t blk, int num,
                if (buf) {
                        free(buf);
                        buf = 0;
+                       stride_length = 0;
                }
                return 0;
        }