]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
fix bug #184: clear out buf to avoid msan use-of-uninitialized-value
authorSebastian Pop <s.pop@samsung.com>
Wed, 15 Aug 2018 19:14:24 +0000 (14:14 -0500)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 17 Sep 2018 09:16:51 +0000 (11:16 +0200)
Do not use bzero as suggested by Mika Lindqvist:
> You shouldn't use bzero() in new code as some compilers, like Visual C++,
> don't have it... New code should just use memset().

test/minigzip.c

index dc06c35acf88cf1187543d34ed8fcbe05b774c73..7868c64dd878788b9615eb6120d75d45a34fd1ef 100644 (file)
@@ -291,6 +291,9 @@ void gz_compress(FILE   *in, gzFile out)
      */
     if (gz_compress_mmap(in, out) == Z_OK) return;
 #endif
+    /* Clear out the contents of buf before reading from the file to avoid
+       MemorySanitizer: use-of-uninitialized-value warnings. */
+    memset(buf, 0, sizeof(buf));
     for (;;) {
         len = (int)fread(buf, 1, sizeof(buf), in);
         if (ferror(in)) {