From: Adrien Schildknecht Date: Wed, 10 Aug 2016 20:43:25 +0000 (-0400) Subject: libext2fs: reset the size of the zeroing buffer X-Git-Tag: v1.43.2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5cc6db0c829353eef4591ac10a9a06c504e65134;p=thirdparty%2Fe2fsprogs.git libext2fs: reset the size of the zeroing buffer 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 Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c index af983c72f..43ffa53ff 100644 --- a/lib/ext2fs/mkjournal.c +++ b/lib/ext2fs/mkjournal.c @@ -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; }