update to 1.5.5

This commit is contained in:
dillon_chen 2023-07-13 15:14:06 +08:00
parent 21cb662350
commit 791f83c2ec
6 changed files with 6 additions and 677 deletions

View File

@ -1,521 +0,0 @@
From 7409f10fed50978ad5dff36540dc0a7aae688688 Mon Sep 17 00:00:00 2001
From: zhangying <zhangying103@huawei.com>
Date: Thu, 2 Feb 2023 14:59:55 +0800
Subject: [PATCH] zstd-add-test-c-result-print.patch
Displays statistics about the execution of all zstd test cases.
---
tests/decodecorpus.c | 17 +++++++++--
tests/fullbench.c | 61 ++++++++++++++++++++++++++++++++++---
tests/fuzzer.c | 16 ++++++++++
tests/invalidDictionaries.c | 10 ++++++
tests/legacy.c | 10 ++++--
tests/playTests.sh | 2 ++
tests/poolTests.c | 24 ++++++++++++---
tests/zstreamtest.c | 18 +++++++++++
8 files changed, 144 insertions(+), 14 deletions(-)
diff --git a/tests/decodecorpus.c b/tests/decodecorpus.c
index 1037a36..5d053aa 100644
--- a/tests/decodecorpus.c
+++ b/tests/decodecorpus.c
@@ -1538,6 +1538,7 @@ static int runTestMode(U32 seed, unsigned numFiles, unsigned const testDurationS
if (numFiles == 0 && !testDurationS) numFiles = 1;
+ DISPLAY("==== test/decodecorpus/runTestMode ====\n");
DISPLAY("seed: %u\n", (unsigned)seed);
for (fnum = 0; fnum < numFiles || UTIL_clockSpanMicro(startClock) < maxClockSpan; fnum++) {
@@ -1549,12 +1550,13 @@ static int runTestMode(U32 seed, unsigned numFiles, unsigned const testDurationS
{ int const ret = (genType == gt_frame) ?
runFrameTest(&seed) :
runBlockTest(&seed);
- if (ret) return ret;
+ if (ret) {DISPLAY("==== results: passed: 0/1, failed: 1/1, skipped: 0/1 ====\n");return ret;}
}
}
DISPLAY("\r%u tests completed: ", fnum);
DISPLAY("OK\n");
+ DISPLAY("==== results: passed: 1/1, failed: 0/1, skipped: 0/1 ====\n");
return 0;
}
@@ -1568,6 +1570,7 @@ static int generateFile(U32 seed, const char* const path,
{
frame_t fr;
+ DISPLAY("==== test/decodecorpus/gerenateFile ====\n");
DISPLAY("seed: %u\n", (unsigned)seed);
{ dictInfo const info = initDictInfo(0, 0, NULL, 0);
@@ -1581,6 +1584,7 @@ static int generateFile(U32 seed, const char* const path,
if (origPath) {
outputBuffer(fr.srcStart, (BYTE*)fr.src - (BYTE*)fr.srcStart, origPath);
}
+ DISPLAY("==== results: passed: 1/1, failed: 0/1, skipped: 0/1 ====\n");
return 0;
}
@@ -1590,6 +1594,7 @@ static int generateCorpus(U32 seed, unsigned numFiles, const char* const path,
char outPath[MAX_PATH];
unsigned fnum;
+ DISPLAY("==== test/decodecorpus/generateCorpus ====\n");
DISPLAY("seed: %u\n", (unsigned)seed);
for (fnum = 0; fnum < numFiles; fnum++) {
@@ -1607,6 +1612,7 @@ static int generateCorpus(U32 seed, unsigned numFiles, const char* const path,
if (snprintf(outPath, MAX_PATH, "%s/z%06u.zst", path, fnum) + 1 > MAX_PATH) {
DISPLAY("Error: path too long\n");
+ DISPLAY("==== results: passed: 0/1, failed: 1/1, skipped: 0/1 ====\n");
return 1;
}
outputBuffer(fr.dataStart, (BYTE*)fr.data - (BYTE*)fr.dataStart, outPath);
@@ -1614,6 +1620,7 @@ static int generateCorpus(U32 seed, unsigned numFiles, const char* const path,
if (origPath) {
if (snprintf(outPath, MAX_PATH, "%s/z%06u", origPath, fnum) + 1 > MAX_PATH) {
DISPLAY("Error: path too long\n");
+ DISPLAY("==== results: passed: 0/1, failed: 1/1, skipped: 0/1 ====\n");
return 1;
}
outputBuffer(fr.srcStart, (BYTE*)fr.src - (BYTE*)fr.srcStart, outPath);
@@ -1621,7 +1628,7 @@ static int generateCorpus(U32 seed, unsigned numFiles, const char* const path,
}
DISPLAY("\r%u/%u \n", fnum, numFiles);
-
+ DISPLAY("==== results: passed: 1/1, failed: 0/1, skipped: 0/1 ====\n");
return 0;
}
@@ -1634,8 +1641,11 @@ static int generateCorpusWithDict(U32 seed, unsigned numFiles, const char* const
U32 const dictID = RAND(&seed);
int errorDetected = 0;
+ DISPLAY("==== test/decodecorpus/generateCorpusWithDict ====\n");
+
if (snprintf(outPath, MAX_PATH, "%s/dictionary", path) + 1 > MAX_PATH) {
DISPLAY("Error: path too long\n");
+ DISPLAY("==== results: passed: 0/1, failed: 1/1, skipped: 0/1 ====\n");
return 1;
}
@@ -1643,6 +1653,7 @@ static int generateCorpusWithDict(U32 seed, unsigned numFiles, const char* const
fullDict = malloc(dictSize);
if (fullDict == NULL) {
DISPLAY("Error: could not allocate space for full dictionary.\n");
+ DISPLAY("==== results: passed: 0/1, failed: 1/1, skipped: 0/1 ====\n");
return 1;
}
@@ -1711,6 +1722,8 @@ static int generateCorpusWithDict(U32 seed, unsigned numFiles, const char* const
}
dictCleanup:
+ DISPLAY("==== results: passed: %d/1, failed: %d/1, skipped: 0/1 ====\n",
+ (1-errorDetected), errorDetected);
free(fullDict);
return errorDetected;
}
diff --git a/tests/fullbench.c b/tests/fullbench.c
index b55ff76..3a6ce2b 100644
--- a/tests/fullbench.c
+++ b/tests/fullbench.c
@@ -500,7 +500,7 @@ static int benchMem(unsigned benchNb,
benchFunction = local_ZSTD_compress_generic_T2_end; benchName = "compress_generic, -T2, end";
break;
default :
- return 0;
+ return -1;
}
/* Allocation */
@@ -700,8 +700,15 @@ static int benchSample(U32 benchNb,
size_t benchedSize, double compressibility,
int cLevel, ZSTD_compressionParameters cparams)
{
+ int ret = 0;
+ int testOk = 0;
+ int testEr = 0;
+
/* Allocation */
void* const origBuff = malloc(benchedSize);
+
+ DISPLAY("==== test/fullbench/benchSample[compressibility:%f] ====\n", compressibility);
+
if (!origBuff) { DISPLAY("\nError: not enough memory!\n"); return 12; }
/* Fill buffer */
@@ -711,12 +718,31 @@ static int benchSample(U32 benchNb,
DISPLAY("\r%70s\r", "");
DISPLAY(" Sample %u bytes : \n", (unsigned)benchedSize);
if (benchNb) {
- benchMem(benchNb, origBuff, benchedSize, cLevel, cparams);
+ ret = benchMem(benchNb, origBuff, benchedSize, cLevel, cparams);
+ if ( 0 == ret )
+ {
+ testOk++;
+ }
+ else if ( 1 == ret )
+ {
+ testEr++;
+ }
} else { /* 0 == run all tests */
for (benchNb=0; benchNb<100; benchNb++) {
- benchMem(benchNb, origBuff, benchedSize, cLevel, cparams);
+ ret = benchMem(benchNb, origBuff, benchedSize, cLevel, cparams);
+ if ( 0 == ret )
+ {
+ testOk++;
+ }
+ else if ( 1 == ret )
+ {
+ testEr++;
+ }
} }
+ DISPLAY("==== results: passed: %d/%d, failed: %d/%d, skipped: 0/%d ====\n",
+ testOk, (testOk+testEr), testEr, (testOk+testEr), (testOk+testEr));
+
free(origBuff);
return 0;
}
@@ -728,6 +754,12 @@ static int benchFiles(U32 benchNb,
{
/* Loop for each file */
int fileIdx;
+ int ret = 0;
+ int testOk = 0;
+ int testEr = 0;
+
+ DISPLAY("==== test/fullbench/benchFiles ====\n");
+
for (fileIdx=0; fileIdx<nbFiles; fileIdx++) {
const char* const inFileName = fileNamesTable[fileIdx];
FILE* const inFile = fopen( inFileName, "rb" );
@@ -769,15 +801,34 @@ static int benchFiles(U32 benchNb,
DISPLAY("\r%70s\r", ""); /* blank line */
DISPLAY(" %s : \n", inFileName);
if (benchNb) {
- benchMem(benchNb, origBuff, benchedSize, cLevel, cparams);
+ ret = benchMem(benchNb, origBuff, benchedSize, cLevel, cparams);
+ if ( 0 == ret )
+ {
+ testOk++;
+ }
+ else if ( 1 == ret )
+ {
+ testEr++;
+ }
} else {
for (benchNb=0; benchNb<100; benchNb++) {
- benchMem(benchNb, origBuff, benchedSize, cLevel, cparams);
+ ret = benchMem(benchNb, origBuff, benchedSize, cLevel, cparams);
+ if ( 0 == ret )
+ {
+ testOk++;
+ }
+ else if ( 1 == ret )
+ {
+ testEr++;
+ }
} }
free(origBuff);
} }
+ DISPLAY("==== results: passed: %d/%d, failed: %d/%d, skipped: 0/%d ====\n",
+ testOk,(testOk+testEr),testEr,(testOk+testEr),(testOk+testEr));
+
return 0;
}
diff --git a/tests/fuzzer.c b/tests/fuzzer.c
index d168d65..f6460d3 100644
--- a/tests/fuzzer.c
+++ b/tests/fuzzer.c
@@ -472,6 +472,8 @@ static int basicUnitTests(U32 const seed, double compressibility)
unsigned testNb=0;
size_t cSize;
+ DISPLAY("==== test/fuzzer/basicUnitTest ====\n");
+
/* Create compressible noise */
if (!CNBuffer || !compressedBuffer || !decodedBuffer) {
DISPLAY("Not enough memory, aborting\n");
@@ -3509,6 +3511,9 @@ static int basicUnitTests(U32 const seed, double compressibility)
#endif /* ZSTD_MULTITHREAD */
_end:
+ DISPLAY("==== results: passed: %d/%d, failed: %d/%d, skipped: 0/%d ====\n",
+ (testNb-testResult), testNb, testResult, testNb, testNb);
+
free(CNBuffer);
free(compressedBuffer);
free(decodedBuffer);
@@ -3531,6 +3536,8 @@ static int longUnitTests(U32 const seed, double compressibility)
unsigned testNb=0;
size_t cSize;
+ DISPLAY("==== test/fuzzer/longUnitTest ====\n");
+
/* Create compressible noise */
if (!CNBuffer || !compressedBuffer || !decodedBuffer) {
DISPLAY("Not enough memory, aborting\n");
@@ -3708,6 +3715,10 @@ static int longUnitTests(U32 const seed, double compressibility)
DISPLAYLEVEL(3, "OK \n");
_end:
+
+ DISPLAY("==== results: passed: %d/%d, failed: %d/%d, skipped: 0/%d ====\n",
+ (testNb-testResult), testNb, testResult, testNb, testNb);
+
free(CNBuffer);
free(compressedBuffer);
free(decodedBuffer);
@@ -3793,6 +3804,8 @@ static int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, U32 const
U64 const maxClockSpan = maxDurationS * SEC_TO_MICRO;
int const cLevelLimiter = bigTests ? 3 : 2;
+ DISPLAY("==== test/fuzzer/fuzzerTests ====\n");
+
/* allocation */
cNoiseBuffer[0] = (BYTE*)malloc (srcBufferSize);
cNoiseBuffer[1] = (BYTE*)malloc (srcBufferSize);
@@ -4056,6 +4069,9 @@ static int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, U32 const
DISPLAY("\r%u fuzzer tests completed \n", testNb-1);
_cleanup:
+ DISPLAY("==== results: passed: %d/1, failed: %d/1, skipped: 0/1 ====\n",
+ (1-result), result);
+
ZSTD_freeCCtx(refCtx);
ZSTD_freeCCtx(ctx);
ZSTD_freeDCtx(dctx);
diff --git a/tests/invalidDictionaries.c b/tests/invalidDictionaries.c
index b71f741..bb2b536 100644
--- a/tests/invalidDictionaries.c
+++ b/tests/invalidDictionaries.c
@@ -9,6 +9,7 @@
*/
#include <stddef.h>
+#include <stdio.h>
#include "zstd.h"
static const char invalidRepCode[] = {
@@ -38,23 +39,32 @@ static const dictionary dictionaries[] = {
{NULL, 0},
};
+#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
+
int main(int argc, const char** argv) {
const dictionary *dict;
for (dict = dictionaries; dict->data != NULL; ++dict) {
ZSTD_CDict *cdict;
ZSTD_DDict *ddict;
+
+ DISPLAY("==== test/invalidDictionaries ====\n");
+
cdict = ZSTD_createCDict(dict->data, dict->size, 1);
if (cdict) {
ZSTD_freeCDict(cdict);
+ DISPLAY("==== results: passed: 0/2, failed: 1/2, skipped: 1/2 ====\n");
return 1;
}
ddict = ZSTD_createDDict(dict->data, dict->size);
if (ddict) {
ZSTD_freeDDict(ddict);
+ DISPLAY("==== results: passed: 1/2, failed: 1/2, skipped: 0/2 ====\n");
return 2;
}
}
+ DISPLAY("==== results: passed: 2/2, failed: 0/2, skipped: 0/2 ====\n");
+
(void)argc;
(void)argv;
return 0;
diff --git a/tests/legacy.c b/tests/legacy.c
index ac4938f..5ebb1cc 100644
--- a/tests/legacy.c
+++ b/tests/legacy.c
@@ -160,14 +160,18 @@ static int testFrameDecoding(void)
int main(void)
{
+ DISPLAY ("==== test/legacy ====\n");
+
{ int const ret = testSimpleAPI();
- if (ret) return ret; }
+ if (ret) {DISPLAY("==== results: passed: 0/3, failed: 1/3, skipped: 2/3 ====\n");return ret;} }
{ int const ret = testStreamingAPI();
- if (ret) return ret; }
+ if (ret) {DISPLAY("==== results: passed: 1/3, failed: 1/3, skipped: 1/3 ====\n");return ret;} }
{ int const ret = testFrameDecoding();
- if (ret) return ret; }
+ if (ret) {DISPLAY("==== results: passed: 2/3, failed: 1/3, skipped: 0/3 ====\n");return ret;} }
DISPLAY("OK\n");
+ DISPLAY("==== results: passed: 3/3, failed: 0/3, skipped: 0/3 ====\n");
+
return 0;
}
diff --git a/tests/playTests.sh b/tests/playTests.sh
index b7a3d88..c152162 100755
--- a/tests/playTests.sh
+++ b/tests/playTests.sh
@@ -1743,3 +1743,5 @@ test -f dictionary
rm -f tmp* dictionary
rm -f tmp*
+
+println "all zstd cli tests passed"
diff --git a/tests/poolTests.c b/tests/poolTests.c
index 08f31c0..972e5c9 100644
--- a/tests/poolTests.c
+++ b/tests/poolTests.c
@@ -24,6 +24,7 @@
} while (0)
#define ASSERT_FALSE(p) ASSERT_TRUE(!(p))
#define ASSERT_EQ(lhs, rhs) ASSERT_TRUE((lhs) == (rhs))
+#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
struct data {
ZSTD_pthread_mutex_t mutex;
@@ -225,11 +226,16 @@ static int testAbruptEnding(void) {
int main(int argc, const char **argv) {
size_t numThreads;
+ unsigned testNb = 0;
+
(void)argc;
(void)argv;
+ DISPLAY("==== test/poolTests ====\n");
+
if (POOL_create(0, 1)) { /* should not be possible */
printf("FAIL: should not create POOL with 0 threads\n");
+ DISPLAY("==== results: passed: 0/1, failed: 0/1, skipped: 0/1 ====\n");
return 1;
}
@@ -240,32 +246,42 @@ int main(int argc, const char **argv) {
(unsigned)queueSize, (unsigned)numThreads);
if (testOrder(numThreads, queueSize)) {
printf("FAIL: testOrder\n");
+ DISPLAY("==== results: passed: %d/%d, failed: 1/%d, skipped: 0/%d ====\n",
+ testNb, (testNb+1), (testNb+1), (testNb+1));
return 1;
}
- printf("SUCCESS: testOrder\n");
+ printf("SUCCESS: testOrder\n");testNb++;
if (testWait(numThreads, queueSize)) {
printf("FAIL: testWait\n");
+ DISPLAY("==== results: passed: %d/%d, failed: 1/%d, skipped: 0/%d ====\n",
+ testNb, (testNb+1), (testNb+1), (testNb+1));
return 1;
}
- printf("SUCCESS: testWait\n");
+ printf("SUCCESS: testWait\n");testNb++;
}
}
if (testThreadReduction()) {
printf("FAIL: thread reduction not effective \n");
+ DISPLAY("==== results: passed: %d/%d, failed: 1/%d, skipped: 0/%d ====\n",
+ testNb, (testNb+1), (testNb+1), (testNb+1));
return 1;
} else {
- printf("SUCCESS: thread reduction effective \n");
+ printf("SUCCESS: thread reduction effective \n");testNb++;
}
if (testAbruptEnding()) {
printf("FAIL: jobs in queue not completed on early end \n");
+ DISPLAY("==== results: passed: %d/%d, failed: 1/%d, skipped: 0/%d ====\n",
+ testNb, (testNb+1), (testNb+1), (testNb+1));
return 1;
} else {
- printf("SUCCESS: all jobs in queue completed on early end \n");
+ printf("SUCCESS: all jobs in queue completed on early end \n");testNb++;
}
printf("PASS: all POOL tests\n");
+ DISPLAY("==== results: passed: %d/%d, failed: 0/%d, skipped: 0/%d ====\n",
+ testNb, testNb, testNb, testNb);
return 0;
}
diff --git a/tests/zstreamtest.c b/tests/zstreamtest.c
index 72fd72e..be300b6 100644
--- a/tests/zstreamtest.c
+++ b/tests/zstreamtest.c
@@ -282,6 +282,8 @@ static int basicUnitTests(U32 seed, double compressibility)
size_t const dictSize = 128 KB;
unsigned dictID = 0;
+ DISPLAY("==== test/zstreamtest/basicUnitTests ====\n");
+
/* Create compressible test buffer */
if (!CNBuffer || !compressedBuffer || !decodedBuffer || !zc || !zd || !mtctx) {
DISPLAY("Not enough memory, aborting \n");
@@ -1691,6 +1693,10 @@ static int basicUnitTests(U32 seed, double compressibility)
DISPLAYLEVEL(3, "OK \n");
_end:
+
+ DISPLAY("==== results: passed: %d/%d, failed: %d/%d, skipped: 0/%d ====\n",
+ (testNb-testResult), testNb, testResult, testNb, testNb);
+
FUZ_freeDictionary(dictionary);
ZSTD_freeCStream(zc);
ZSTD_freeDStream(zd);
@@ -1778,6 +1784,8 @@ static int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double co
U32 oldTestLog = 0;
U32 const cLevelMax = bigTests ? (U32)ZSTD_maxCLevel() : g_cLevelMax_smallTests;
+ DISPLAY("==== test/zstreamtest/fuzzerTests ====\n");
+
/* allocations */
cNoiseBuffer[0] = (BYTE*)malloc (srcBufferSize);
cNoiseBuffer[1] = (BYTE*)malloc (srcBufferSize);
@@ -1989,6 +1997,10 @@ static int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double co
DISPLAY("\r%u fuzzer tests completed \n", testNb);
_cleanup:
+
+ DISPLAY("==== results: passed: %d/1, failed: %d/1, skipped: 0/1 ====\n",
+ (1-result), result);
+
ZSTD_freeCStream(zc);
ZSTD_freeDStream(zd);
ZSTD_freeDStream(zd_noise);
@@ -2049,6 +2061,8 @@ static int fuzzerTests_newAPI(U32 seed, int nbTests, int startTest,
U32 const nbThreadsMax = bigTests ? 4 : 2;
ZSTD_CCtx_params* cctxParams = ZSTD_createCCtxParams();
+ DISPLAY("==== test/zstreamtest/fuzzerTests_newAPI ====\n");
+
/* allocations */
cNoiseBuffer[0] = (BYTE*)malloc (srcBufferSize);
cNoiseBuffer[1] = (BYTE*)malloc (srcBufferSize);
@@ -2423,6 +2437,10 @@ static int fuzzerTests_newAPI(U32 seed, int nbTests, int startTest,
DISPLAY("\r%u fuzzer tests completed \n", testNb-1);
_cleanup:
+
+ DISPLAY("==== results: passed: %d/1, failed: %d/1, skipped: 0/1 ====\n",
+ (1-result), result);
+
ZSTD_freeCCtx(zc);
ZSTD_freeDStream(zd);
ZSTD_freeDStream(zd_noise);
--
2.33.0

View File

@ -1,85 +0,0 @@
From f9f27de91c89d826c6a39c3ef44fb1b02f9a43aa Mon Sep 17 00:00:00 2001
From: Elliot Gorokhovsky <embg@fb.com>
Date: Fri, 29 Jul 2022 14:44:22 -0700
Subject: [PATCH] Disallow empty output directory
Reference:https://github.com/facebook/zstd/commit/f9f27de91c89d826c6a39c3ef44fb1b02f9a43aa
Conflict:NA
---
programs/zstdcli.c | 18 ++++++++++++++++--
tests/cli-tests/basic/output_dir.sh | 7 +++++++
.../cli-tests/basic/output_dir.sh.stderr.exact | 2 ++
.../cli-tests/basic/output_dir.sh.stdout.exact | 2 ++
4 files changed, 27 insertions(+), 2 deletions(-)
create mode 100755 tests/cli-tests/basic/output_dir.sh
create mode 100644 tests/cli-tests/basic/output_dir.sh.stderr.exact
create mode 100644 tests/cli-tests/basic/output_dir.sh.stdout.exact
diff --git a/programs/zstdcli.c b/programs/zstdcli.c
index bfe18c0..50ef3ba 100644
--- a/programs/zstdcli.c
+++ b/programs/zstdcli.c
@@ -990,7 +990,14 @@ int main(int argCount, const char* argv[])
if (longCommandWArg(&argument, "--stream-size=")) { streamSrcSize = readSizeTFromChar(&argument); continue; }
if (longCommandWArg(&argument, "--target-compressed-block-size=")) { targetCBlockSize = readSizeTFromChar(&argument); continue; }
if (longCommandWArg(&argument, "--size-hint=")) { srcSizeHint = readSizeTFromChar(&argument); continue; }
- if (longCommandWArg(&argument, "--output-dir-flat")) { NEXT_FIELD(outDirName); continue; }
+ if (longCommandWArg(&argument, "--output-dir-flat")) {
+ NEXT_FIELD(outDirName);
+ if (strlen(outDirName) == 0) {
+ DISPLAY("error: output dir cannot be empty string (did you mean to pass '.' instead?)\n");
+ CLEAN_RETURN(1);
+ }
+ continue;
+ }
#ifdef ZSTD_MULTITHREAD
if (longCommandWArg(&argument, "--auto-threads")) {
const char* threadDefault = NULL;
@@ -1001,7 +1008,14 @@ int main(int argCount, const char* argv[])
}
#endif
#ifdef UTIL_HAS_MIRRORFILELIST
- if (longCommandWArg(&argument, "--output-dir-mirror")) { NEXT_FIELD(outMirroredDirName); continue; }
+ if (longCommandWArg(&argument, "--output-dir-mirror")) {
+ NEXT_FIELD(outMirroredDirName);
+ if (strlen(outMirroredDirName) == 0) {
+ DISPLAY("error: output dir cannot be empty string (did you mean to pass '.' instead?)\n");
+ CLEAN_RETURN(1);
+ }
+ continue;
+ }
#endif
#ifndef ZSTD_NOTRACE
if (longCommandWArg(&argument, "--trace")) { char const* traceFile; NEXT_FIELD(traceFile); TRACE_enable(traceFile); continue; }
diff --git a/tests/cli-tests/basic/output_dir.sh b/tests/cli-tests/basic/output_dir.sh
new file mode 100755
index 0000000..a8819d2
--- /dev/null
+++ b/tests/cli-tests/basic/output_dir.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+println "+ zstd -r * --output-dir-mirror=\"\""
+zstd -r * --output-dir-mirror="" && die "Should not allow empty output dir!"
+println "+ zstd -r * --output-dir-flat=\"\""
+zstd -r * --output-dir-flat="" && die "Should not allow empty output dir!"
+exit 0
diff --git a/tests/cli-tests/basic/output_dir.sh.stderr.exact b/tests/cli-tests/basic/output_dir.sh.stderr.exact
new file mode 100644
index 0000000..e12b504
--- /dev/null
+++ b/tests/cli-tests/basic/output_dir.sh.stderr.exact
@@ -0,0 +1,2 @@
+error: output dir cannot be empty string (did you mean to pass '.' instead?)
+error: output dir cannot be empty string (did you mean to pass '.' instead?)
diff --git a/tests/cli-tests/basic/output_dir.sh.stdout.exact b/tests/cli-tests/basic/output_dir.sh.stdout.exact
new file mode 100644
index 0000000..1e478cd
--- /dev/null
+++ b/tests/cli-tests/basic/output_dir.sh.stdout.exact
@@ -0,0 +1,2 @@
++ zstd -r * --output-dir-mirror=""
++ zstd -r * --output-dir-flat=""
--
2.27.0

View File

@ -1,63 +0,0 @@
From e1873ad576cb478fff0e6e44ad99599cd5fd2846 Mon Sep 17 00:00:00 2001
From: Elliot Gorokhovsky <embg@fb.com>
Date: Fri, 29 Jul 2022 11:10:47 -0700
Subject: [PATCH] Fix buffer underflow for null dir1
---
programs/util.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/programs/util.c b/programs/util.c
index f53eb03fbe..b874344c4d 100644
--- a/programs/util.c
+++ b/programs/util.c
@@ -870,30 +870,30 @@ static const char * trimPath(const char *pathname)
static char* mallocAndJoin2Dir(const char *dir1, const char *dir2)
{
- const size_t dir1Size = strlen(dir1);
- const size_t dir2Size = strlen(dir2);
- char *outDirBuffer, *buffer, trailingChar;
-
assert(dir1 != NULL && dir2 != NULL);
- outDirBuffer = (char *) malloc(dir1Size + dir2Size + 2);
- CONTROL(outDirBuffer != NULL);
+ { const size_t dir1Size = strlen(dir1);
+ const size_t dir2Size = strlen(dir2);
+ char *outDirBuffer, *buffer;
- memcpy(outDirBuffer, dir1, dir1Size);
- outDirBuffer[dir1Size] = '\0';
+ outDirBuffer = (char *) malloc(dir1Size + dir2Size + 2);
+ CONTROL(outDirBuffer != NULL);
- if (dir2[0] == '.')
- return outDirBuffer;
+ memcpy(outDirBuffer, dir1, dir1Size);
+ outDirBuffer[dir1Size] = '\0';
- buffer = outDirBuffer + dir1Size;
- trailingChar = *(buffer - 1);
- if (trailingChar != PATH_SEP) {
- *buffer = PATH_SEP;
- buffer++;
- }
- memcpy(buffer, dir2, dir2Size);
- buffer[dir2Size] = '\0';
+ if (dir2[0] == '.')
+ return outDirBuffer;
- return outDirBuffer;
+ buffer = outDirBuffer + dir1Size;
+ if (dir1Size > 0 && *(buffer - 1) != PATH_SEP) {
+ *buffer = PATH_SEP;
+ buffer++;
+ }
+ memcpy(buffer, dir2, dir2Size);
+ buffer[dir2Size] = '\0';
+
+ return outDirBuffer;
+ }
}
/* this function will return NULL if input srcFileName is not valid name for mirrored output path */

Binary file not shown.

BIN
zstd-1.5.5.tar.gz Normal file

Binary file not shown.

View File

@ -1,18 +1,13 @@
%bcond_without pzstd
Name: zstd
Version: 1.5.2
Release: 2
Version: 1.5.5
Release: 1
Summary: A fast lossless compression algorithm
License: BSD and GPLv2
URL: https://github.com/facebook/zstd
Source0: https://github.com/facebook/zstd/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch6000: backport-0001-CVE-2022-4899.patch
Patch6001: backport-0002-CVE-2022-4899.patch
Patch9000: add-test-c-result-print.patch
BuildRequires: gtest-devel gcc-c++ pkg-config
Provides: libzstd
@ -53,7 +48,7 @@ done
%endif
%check
make -C tests test
make -C tests test-zstd
%if %{with pzstd}
make -C contrib/pzstd test CXXFLAGS="$RPM_OPT_FLAGS -std=c++11"
%endif
@ -90,6 +85,9 @@ install -D -m644 programs/zstd.1 %{buildroot}%{_mandir}/man1/pzstd.1
%{_mandir}/man1/*.1*
%changelog
* Thu Jul 13 2023 dillon chen <dillon.chen@gmail.com> - 1.5.5-1
* zstd update to 1.5.5
* Mon Apr 3 2023 zhoupengcheng <zhoupengcheng11@huawei.com> - 1.5.2.2
* fix CVE-2022-4899