diff mbox series

[liburing,v1,03/10] test/file-verify: Fix reading from uninitialized buffer

Message ID 20220810002735.2260172-4-ammar.faizi@intel.com (mailing list archive)
State New
Headers show
Series liburing test fixes | expand

Commit Message

Ammar Faizi Aug. 10, 2022, 12:31 a.m. UTC
From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

Fix this:

  ==3054556== Conditional jump or move depends on uninitialised value(s)
  ==3054556==    at 0x1099DB: verify_buf (file-verify.c:48)
  ==3054556==    by 0x10A506: test (file-verify.c:449)
  ==3054556==    by 0x109353: main (file-verify.c:538)

Link: https://github.com/axboe/liburing/issues/640
Reported-by: Vitaly Chikunov <vt@altlinux.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 test/file-verify.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/test/file-verify.c b/test/file-verify.c
index 595dafd..b1a8fd4 100644
--- a/test/file-verify.c
+++ b/test/file-verify.c
@@ -347,13 +347,16 @@  static int test(struct io_uring *ring, const char *fname, int buffered,
 				void *ptr;
 
 				t_posix_memalign(&ptr, 4096, CHUNK_SIZE / nr_vecs);
+				memset(ptr, 0, CHUNK_SIZE / nr_vecs);
 				vecs[j][i].iov_base = ptr;
 				vecs[j][i].iov_len = CHUNK_SIZE / nr_vecs;
 			}
 		}
 	} else {
-		for (j = 0; j < READ_BATCH; j++)
+		for (j = 0; j < READ_BATCH; j++) {
 			t_posix_memalign(&buf[j], 4096, CHUNK_SIZE);
+			memset(buf[j], 0, CHUNK_SIZE);
+		}
 		nr_vecs = 0;
 	}