]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
null decompress buffer test and ubsan flag added 3253/head 3254/head
authorDanielle Rozenblit <drozenblit@fb.com>
Tue, 6 Sep 2022 21:34:55 +0000 (14:34 -0700)
committerDanielle Rozenblit <drozenblit@fb.com>
Tue, 6 Sep 2022 21:34:55 +0000 (14:34 -0700)
tests/Makefile
tests/zstreamtest.c
tests/zstreamtest_ubsan [new file with mode: 0755]

index cb77b0160a85a160effc984f2cfd449830a452b2..088a098a6f0fafdfa89cb56e5445d4d55bd90bda 100644 (file)
@@ -183,6 +183,10 @@ zstreamtest_tsan : CFLAGS += -fsanitize=thread
 zstreamtest_tsan : $(ZSTREAMFILES)
        $(LINK.c) $(MULTITHREAD) $^ -o $@$(EXT)
 
+zstreamtest_ubsan : CFLAGS += -fsanitize=undefined
+zstreamtest_ubsan : $(ZSTREAMFILES)
+       $(LINK.c) $(MULTITHREAD) $^ -o $@$(EXT)
+
 # note : broken : requires symbols unavailable from dynamic library
 zstreamtest-dll : $(ZSTDDIR)/common/xxhash.c  # xxh symbols not exposed from dll
 zstreamtest-dll : $(ZSTREAM_LOCAL_FILES)
index 3fcdd5399a4ee071ca198b535614527e752a15a4..d4c9823e2ff6d5af9859a1f3d47307b489d1b905 100644 (file)
@@ -548,6 +548,15 @@ static int basicUnitTests(U32 seed, double compressibility)
     {   size_t const ret = ZSTD_decompressStream(zd, &outBuff, &inBuff);
         if (ret != 0) goto _output_error;
     }
+    inBuff.src = NULL;
+    inBuff.size = 0;
+    inBuff.pos = 0;
+    outBuff.dst = NULL;
+    outBuff.size = 0;
+    outBuff.pos = 0;
+    CHECK_Z( ZSTD_initDStream(zd) );
+    CHECK_Z(ZSTD_decompressStream(zd, &outBuff, &inBuff));
+
     DISPLAYLEVEL(3, "OK\n");
     /* _srcSize compression test */
     DISPLAYLEVEL(3, "test%3i : compress_srcSize %u bytes : ", testNb++, COMPRESSIBLE_NOISE_LENGTH);
diff --git a/tests/zstreamtest_ubsan b/tests/zstreamtest_ubsan
new file mode 100755 (executable)
index 0000000..55a36fd
Binary files /dev/null and b/tests/zstreamtest_ubsan differ