Skip to content

Commit 86caab5

Browse files
authored
Merge pull request #3981 from terrelln/2024-03-19-generate-sequences
Fix & fuzz ZSTD_generateSequences
2 parents 741b87b + 731f4b7 commit 86caab5

File tree

8 files changed

+231
-56
lines changed

8 files changed

+231
-56
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ port: sparc64 support validation in CI, by @Cyan4973
3333
port: AIX compatibility, by @likema
3434
port: HP-UX compatibility, by @likema
3535
doc: Improved specification accuracy, by @elasota
36+
bug: Fix and deprecate ZSTD_generateSequences (#3981)
3637

3738
v1.5.5 (Apr 2023)
3839
fix: fix rare corruption bug affecting the high compression mode, reported by @danlark1 (#3517, @terrelln)

lib/compress/zstd_compress.c

Lines changed: 85 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3361,29 +3361,38 @@ static size_t ZSTD_buildSeqStore(ZSTD_CCtx* zc, const void* src, size_t srcSize)
33613361
return ZSTDbss_compress;
33623362
}
33633363

3364-
static void ZSTD_copyBlockSequences(ZSTD_CCtx* zc)
3364+
static size_t ZSTD_copyBlockSequences(SeqCollector* seqCollector, const seqStore_t* seqStore, const U32 prevRepcodes[ZSTD_REP_NUM])
33653365
{
3366-
const seqStore_t* seqStore = ZSTD_getSeqStore(zc);
3367-
const seqDef* seqStoreSeqs = seqStore->sequencesStart;
3368-
size_t seqStoreSeqSize = seqStore->sequences - seqStoreSeqs;
3369-
size_t seqStoreLiteralsSize = (size_t)(seqStore->lit - seqStore->litStart);
3370-
size_t literalsRead = 0;
3371-
size_t lastLLSize;
3366+
const seqDef* inSeqs = seqStore->sequencesStart;
3367+
const size_t nbInSequences = seqStore->sequences - inSeqs;
3368+
const size_t nbInLiterals = (size_t)(seqStore->lit - seqStore->litStart);
33723369

3373-
ZSTD_Sequence* outSeqs = &zc->seqCollector.seqStart[zc->seqCollector.seqIndex];
3370+
ZSTD_Sequence* outSeqs = seqCollector->seqIndex == 0 ? seqCollector->seqStart : seqCollector->seqStart + seqCollector->seqIndex;
3371+
const size_t nbOutSequences = nbInSequences + 1;
3372+
size_t nbOutLiterals = 0;
3373+
repcodes_t repcodes;
33743374
size_t i;
3375-
repcodes_t updatedRepcodes;
33763375

3377-
assert(zc->seqCollector.seqIndex + 1 < zc->seqCollector.maxSequences);
3378-
/* Ensure we have enough space for last literals "sequence" */
3379-
assert(zc->seqCollector.maxSequences >= seqStoreSeqSize + 1);
3380-
ZSTD_memcpy(updatedRepcodes.rep, zc->blockState.prevCBlock->rep, sizeof(repcodes_t));
3381-
for (i = 0; i < seqStoreSeqSize; ++i) {
3382-
U32 rawOffset = seqStoreSeqs[i].offBase - ZSTD_REP_NUM;
3383-
outSeqs[i].litLength = seqStoreSeqs[i].litLength;
3384-
outSeqs[i].matchLength = seqStoreSeqs[i].mlBase + MINMATCH;
3376+
/* Bounds check that we have enough space for every input sequence
3377+
* and the block delimiter
3378+
*/
3379+
assert(seqCollector->seqIndex <= seqCollector->maxSequences);
3380+
RETURN_ERROR_IF(
3381+
nbOutSequences > (size_t)(seqCollector->maxSequences - seqCollector->seqIndex),
3382+
dstSize_tooSmall,
3383+
"Not enough space to copy sequences");
3384+
3385+
ZSTD_memcpy(&repcodes, prevRepcodes, sizeof(repcodes));
3386+
for (i = 0; i < nbInSequences; ++i) {
3387+
U32 rawOffset;
3388+
outSeqs[i].litLength = inSeqs[i].litLength;
3389+
outSeqs[i].matchLength = inSeqs[i].mlBase + MINMATCH;
33853390
outSeqs[i].rep = 0;
33863391

3392+
/* Handle the possible single length >= 64K
3393+
* There can only be one because we add MINMATCH to every match length,
3394+
* and blocks are at most 128K.
3395+
*/
33873396
if (i == seqStore->longLengthPos) {
33883397
if (seqStore->longLengthType == ZSTD_llt_literalLength) {
33893398
outSeqs[i].litLength += 0x10000;
@@ -3392,41 +3401,55 @@ static void ZSTD_copyBlockSequences(ZSTD_CCtx* zc)
33923401
}
33933402
}
33943403

3395-
if (seqStoreSeqs[i].offBase <= ZSTD_REP_NUM) {
3396-
/* Derive the correct offset corresponding to a repcode */
3397-
outSeqs[i].rep = seqStoreSeqs[i].offBase;
3404+
/* Determine the raw offset given the offBase, which may be a repcode. */
3405+
if (OFFBASE_IS_REPCODE(inSeqs[i].offBase)) {
3406+
const U32 repcode = OFFBASE_TO_REPCODE(inSeqs[i].offBase);
3407+
assert(repcode > 0);
3408+
outSeqs[i].rep = repcode;
33983409
if (outSeqs[i].litLength != 0) {
3399-
rawOffset = updatedRepcodes.rep[outSeqs[i].rep - 1];
3410+
rawOffset = repcodes.rep[repcode - 1];
34003411
} else {
3401-
if (outSeqs[i].rep == 3) {
3402-
rawOffset = updatedRepcodes.rep[0] - 1;
3412+
if (repcode == 3) {
3413+
assert(repcodes.rep[0] > 1);
3414+
rawOffset = repcodes.rep[0] - 1;
34033415
} else {
3404-
rawOffset = updatedRepcodes.rep[outSeqs[i].rep];
3416+
rawOffset = repcodes.rep[repcode];
34053417
}
34063418
}
3419+
} else {
3420+
rawOffset = OFFBASE_TO_OFFSET(inSeqs[i].offBase);
34073421
}
34083422
outSeqs[i].offset = rawOffset;
3409-
/* seqStoreSeqs[i].offset == offCode+1, and ZSTD_updateRep() expects offCode
3410-
so we provide seqStoreSeqs[i].offset - 1 */
3411-
ZSTD_updateRep(updatedRepcodes.rep,
3412-
seqStoreSeqs[i].offBase,
3413-
seqStoreSeqs[i].litLength == 0);
3414-
literalsRead += outSeqs[i].litLength;
3423+
3424+
/* Update repcode history for the sequence */
3425+
ZSTD_updateRep(repcodes.rep,
3426+
inSeqs[i].offBase,
3427+
inSeqs[i].litLength == 0);
3428+
3429+
nbOutLiterals += outSeqs[i].litLength;
34153430
}
34163431
/* Insert last literals (if any exist) in the block as a sequence with ml == off == 0.
34173432
* If there are no last literals, then we'll emit (of: 0, ml: 0, ll: 0), which is a marker
34183433
* for the block boundary, according to the API.
34193434
*/
3420-
assert(seqStoreLiteralsSize >= literalsRead);
3421-
lastLLSize = seqStoreLiteralsSize - literalsRead;
3422-
outSeqs[i].litLength = (U32)lastLLSize;
3423-
outSeqs[i].matchLength = outSeqs[i].offset = outSeqs[i].rep = 0;
3424-
seqStoreSeqSize++;
3425-
zc->seqCollector.seqIndex += seqStoreSeqSize;
3435+
assert(nbInLiterals >= nbOutLiterals);
3436+
{
3437+
const size_t lastLLSize = nbInLiterals - nbOutLiterals;
3438+
outSeqs[nbInSequences].litLength = (U32)lastLLSize;
3439+
outSeqs[nbInSequences].matchLength = 0;
3440+
outSeqs[nbInSequences].offset = 0;
3441+
assert(nbOutSequences == nbInSequences + 1);
3442+
}
3443+
seqCollector->seqIndex += nbOutSequences;
3444+
assert(seqCollector->seqIndex <= seqCollector->maxSequences);
3445+
3446+
return 0;
34263447
}
34273448

34283449
size_t ZSTD_sequenceBound(size_t srcSize) {
3429-
return (srcSize / ZSTD_MINMATCH_MIN) + 1;
3450+
const size_t maxNbSeq = (srcSize / ZSTD_MINMATCH_MIN) + 1;
3451+
const size_t maxNbDelims = (srcSize / ZSTD_BLOCKSIZE_MAX_MIN) + 1;
3452+
return maxNbSeq + maxNbDelims;
34303453
}
34313454

34323455
size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
@@ -3435,6 +3458,16 @@ size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
34353458
const size_t dstCapacity = ZSTD_compressBound(srcSize);
34363459
void* dst = ZSTD_customMalloc(dstCapacity, ZSTD_defaultCMem);
34373460
SeqCollector seqCollector;
3461+
{
3462+
int targetCBlockSize;
3463+
FORWARD_IF_ERROR(ZSTD_CCtx_getParameter(zc, ZSTD_c_targetCBlockSize, &targetCBlockSize), "");
3464+
RETURN_ERROR_IF(targetCBlockSize != 0, parameter_unsupported, "targetCBlockSize != 0");
3465+
}
3466+
{
3467+
int nbWorkers;
3468+
FORWARD_IF_ERROR(ZSTD_CCtx_getParameter(zc, ZSTD_c_nbWorkers, &nbWorkers), "");
3469+
RETURN_ERROR_IF(nbWorkers != 0, parameter_unsupported, "nbWorkers != 0");
3470+
}
34383471

34393472
RETURN_ERROR_IF(dst == NULL, memory_allocation, "NULL pointer!");
34403473

@@ -3444,8 +3477,12 @@ size_t ZSTD_generateSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
34443477
seqCollector.maxSequences = outSeqsSize;
34453478
zc->seqCollector = seqCollector;
34463479

3447-
ZSTD_compress2(zc, dst, dstCapacity, src, srcSize);
3448-
ZSTD_customFree(dst, ZSTD_defaultCMem);
3480+
{
3481+
const size_t ret = ZSTD_compress2(zc, dst, dstCapacity, src, srcSize);
3482+
ZSTD_customFree(dst, ZSTD_defaultCMem);
3483+
FORWARD_IF_ERROR(ret, "ZSTD_compress2 failed");
3484+
}
3485+
assert(zc->seqCollector.seqIndex <= ZSTD_sequenceBound(srcSize));
34493486
return zc->seqCollector.seqIndex;
34503487
}
34513488

@@ -4038,8 +4075,9 @@ ZSTD_compressSeqStore_singleBlock(ZSTD_CCtx* zc,
40384075
cSeqsSize = 1;
40394076
}
40404077

4078+
/* Sequence collection not supported when block splitting */
40414079
if (zc->seqCollector.collectSequences) {
4042-
ZSTD_copyBlockSequences(zc);
4080+
FORWARD_IF_ERROR(ZSTD_copyBlockSequences(&zc->seqCollector, seqStore, dRepOriginal.rep), "copyBlockSequences failed");
40434081
ZSTD_blockState_confirmRepcodesAndEntropyTables(&zc->blockState);
40444082
return 0;
40454083
}
@@ -4261,6 +4299,7 @@ ZSTD_compressBlock_splitBlock(ZSTD_CCtx* zc,
42614299
if (bss == ZSTDbss_noCompress) {
42624300
if (zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid)
42634301
zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check;
4302+
RETURN_ERROR_IF(zc->seqCollector.collectSequences, sequenceProducer_failed, "Uncompressible block");
42644303
cSize = ZSTD_noCompressBlock(dst, dstCapacity, src, srcSize, lastBlock);
42654304
FORWARD_IF_ERROR(cSize, "ZSTD_noCompressBlock failed");
42664305
DEBUGLOG(4, "ZSTD_compressBlock_splitBlock: Nocompress block");
@@ -4293,11 +4332,15 @@ ZSTD_compressBlock_internal(ZSTD_CCtx* zc,
42934332

42944333
{ const size_t bss = ZSTD_buildSeqStore(zc, src, srcSize);
42954334
FORWARD_IF_ERROR(bss, "ZSTD_buildSeqStore failed");
4296-
if (bss == ZSTDbss_noCompress) { cSize = 0; goto out; }
4335+
if (bss == ZSTDbss_noCompress) {
4336+
RETURN_ERROR_IF(zc->seqCollector.collectSequences, sequenceProducer_failed, "Uncompressible block");
4337+
cSize = 0;
4338+
goto out;
4339+
}
42974340
}
42984341

42994342
if (zc->seqCollector.collectSequences) {
4300-
ZSTD_copyBlockSequences(zc);
4343+
FORWARD_IF_ERROR(ZSTD_copyBlockSequences(&zc->seqCollector, ZSTD_getSeqStore(zc), zc->blockState.prevCBlock->rep), "copyBlockSequences failed");
43014344
ZSTD_blockState_confirmRepcodesAndEntropyTables(&zc->blockState);
43024345
return 0;
43034346
}

lib/compress/zstdmt_compress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static void ZSTDMT_freeBufferPool(ZSTDMT_bufferPool* bufPool)
121121

122122
static ZSTDMT_bufferPool* ZSTDMT_createBufferPool(unsigned maxNbBuffers, ZSTD_customMem cMem)
123123
{
124-
ZSTDMT_bufferPool* const bufPool =
124+
ZSTDMT_bufferPool* const bufPool =
125125
(ZSTDMT_bufferPool*)ZSTD_customCalloc(sizeof(ZSTDMT_bufferPool), cMem);
126126
if (bufPool==NULL) return NULL;
127127
if (ZSTD_pthread_mutex_init(&bufPool->poolMutex, NULL)) {
@@ -380,7 +380,7 @@ static void ZSTDMT_freeCCtxPool(ZSTDMT_CCtxPool* pool)
380380
static ZSTDMT_CCtxPool* ZSTDMT_createCCtxPool(int nbWorkers,
381381
ZSTD_customMem cMem)
382382
{
383-
ZSTDMT_CCtxPool* const cctxPool =
383+
ZSTDMT_CCtxPool* const cctxPool =
384384
(ZSTDMT_CCtxPool*) ZSTD_customCalloc(sizeof(ZSTDMT_CCtxPool), cMem);
385385
assert(nbWorkers > 0);
386386
if (!cctxPool) return NULL;

lib/zstd.h

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,25 +1538,38 @@ typedef enum {
15381538
ZSTDLIB_STATIC_API size_t ZSTD_sequenceBound(size_t srcSize);
15391539

15401540
/*! ZSTD_generateSequences() :
1541+
* WARNING: This function is meant for debugging and informational purposes ONLY!
1542+
* Its implementation is flawed, and it will be deleted in a future version.
1543+
* It is not guaranteed to succeed, as there are several cases where it will give
1544+
* up and fail. You should NOT use this function in production code.
1545+
*
1546+
* This function is deprecated, and will be removed in a future version.
1547+
*
15411548
* Generate sequences using ZSTD_compress2(), given a source buffer.
15421549
*
1550+
* @param zc The compression context to be used for ZSTD_compress2(). Set any
1551+
* compression parameters you need on this context.
1552+
* @param outSeqs The output sequences buffer of size @p outSeqsSize
1553+
* @param outSeqsSize The size of the output sequences buffer.
1554+
* ZSTD_sequenceBound(srcSize) is an upper bound on the number
1555+
* of sequences that can be generated.
1556+
* @param src The source buffer to generate sequences from of size @p srcSize.
1557+
* @param srcSize The size of the source buffer.
1558+
*
15431559
* Each block will end with a dummy sequence
15441560
* with offset == 0, matchLength == 0, and litLength == length of last literals.
15451561
* litLength may be == 0, and if so, then the sequence of (of: 0 ml: 0 ll: 0)
15461562
* simply acts as a block delimiter.
15471563
*
1548-
* @zc can be used to insert custom compression params.
1549-
* This function invokes ZSTD_compress2().
1550-
*
1551-
* The output of this function can be fed into ZSTD_compressSequences() with CCtx
1552-
* setting of ZSTD_c_blockDelimiters as ZSTD_sf_explicitBlockDelimiters
1553-
* @return : number of sequences generated
1564+
* @returns The number of sequences generated, necessarily less than
1565+
* ZSTD_sequenceBound(srcSize), or an error code that can be checked
1566+
* with ZSTD_isError().
15541567
*/
1555-
1568+
ZSTD_DEPRECATED("For debugging only, will be replaced by ZSTD_extractSequences()")
15561569
ZSTDLIB_STATIC_API size_t
1557-
ZSTD_generateSequences( ZSTD_CCtx* zc,
1558-
ZSTD_Sequence* outSeqs, size_t outSeqsSize,
1559-
const void* src, size_t srcSize);
1570+
ZSTD_generateSequences(ZSTD_CCtx* zc,
1571+
ZSTD_Sequence* outSeqs, size_t outSeqsSize,
1572+
const void* src, size_t srcSize);
15601573

15611574
/*! ZSTD_mergeBlockDelimiters() :
15621575
* Given an array of ZSTD_Sequence, remove all sequences that represent block delimiters/last literals

tests/fuzz/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ FUZZ_TARGETS := \
125125
seekable_roundtrip \
126126
huf_round_trip \
127127
huf_decompress \
128-
decompress_cross_format
128+
decompress_cross_format \
129+
generate_sequences
129130

130131
all: libregression.a $(FUZZ_TARGETS)
131132

@@ -239,10 +240,13 @@ huf_round_trip: $(FUZZ_HEADERS) $(FUZZ_ROUND_TRIP_OBJ) rt_fuzz_huf_round_trip.o
239240

240241
huf_decompress: $(FUZZ_HEADERS) $(FUZZ_DECOMPRESS_OBJ) d_fuzz_huf_decompress.o
241242
$(CXX) $(FUZZ_TARGET_FLAGS) $(FUZZ_DECOMPRESS_OBJ) d_fuzz_huf_decompress.o $(LIB_FUZZING_ENGINE) -o $@
242-
243+
243244
decompress_cross_format: $(FUZZ_HEADERS) $(FUZZ_DECOMPRESS_OBJ) d_fuzz_decompress_cross_format.o
244245
$(CXX) $(FUZZ_TARGET_FLAGS) $(FUZZ_DECOMPRESS_OBJ) d_fuzz_decompress_cross_format.o $(LIB_FUZZING_ENGINE) -o $@
245246

247+
generate_sequences: $(FUZZ_HEADERS) $(FUZZ_ROUND_TRIP_OBJ) rt_fuzz_generate_sequences.o
248+
$(CXX) $(FUZZ_TARGET_FLAGS) $(FUZZ_ROUND_TRIP_OBJ) rt_fuzz_generate_sequences.o $(LIB_FUZZING_ENGINE) -o $@
249+
246250
libregression.a: $(FUZZ_HEADERS) $(PRGDIR)/util.h $(PRGDIR)/util.c d_fuzz_regression_driver.o
247251
$(AR) $(FUZZ_ARFLAGS) $@ d_fuzz_regression_driver.o
248252

tests/fuzz/fuzz.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(self, input_type, frame_type=FrameType.ZSTD):
6666
'huf_round_trip': TargetInfo(InputType.RAW_DATA),
6767
'huf_decompress': TargetInfo(InputType.RAW_DATA),
6868
'decompress_cross_format': TargetInfo(InputType.RAW_DATA),
69+
'generate_sequences': TargetInfo(InputType.RAW_DATA),
6970
}
7071
TARGETS = list(TARGET_INFO.keys())
7172
ALL_TARGETS = TARGETS + ['all']

tests/fuzz/generate_sequences.c

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under both the BSD-style license (found in the
6+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
7+
* in the COPYING file in the root directory of this source tree).
8+
* You may select, at your option, one of the above-listed licenses.
9+
*/
10+
11+
#define ZSTD_STATIC_LINKING_ONLY
12+
13+
#include <stddef.h>
14+
#include <stdint.h>
15+
#include <string.h>
16+
#include <stdlib.h>
17+
18+
#include "fuzz_data_producer.h"
19+
#include "fuzz_helpers.h"
20+
#include "zstd_helpers.h"
21+
22+
/**
23+
* This fuzz target ensures that ZSTD_generateSequences() does not crash and
24+
* if it succeeds that ZSTD_compressSequences() round trips.
25+
*/
26+
27+
static void testRoundTrip(ZSTD_CCtx* cctx, ZSTD_Sequence const* seqs, size_t nbSeqs, const void* src, size_t srcSize) {
28+
/* Compress the sequences with block delimiters */
29+
const size_t compressBound = ZSTD_compressBound(srcSize);
30+
void* dst = FUZZ_malloc(compressBound);
31+
FUZZ_ASSERT(dst);
32+
33+
size_t compressedSize = ZSTD_compressSequences(cctx, dst, compressBound, seqs, nbSeqs, src, srcSize);
34+
FUZZ_ZASSERT(compressedSize);
35+
36+
void* decompressed = FUZZ_malloc(srcSize);
37+
FUZZ_ASSERT(srcSize == 0 || decompressed);
38+
size_t decompressedSize = ZSTD_decompress(decompressed, srcSize, dst, compressedSize);
39+
FUZZ_ZASSERT(decompressedSize);
40+
FUZZ_ASSERT(decompressedSize == srcSize);
41+
if (srcSize != 0) {
42+
FUZZ_ASSERT(!memcmp(src, decompressed, srcSize));
43+
}
44+
45+
free(decompressed);
46+
free(dst);
47+
}
48+
49+
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
50+
51+
FUZZ_dataProducer_t *producer = FUZZ_dataProducer_create(data, size);
52+
size = FUZZ_dataProducer_reserveDataPrefix(producer);
53+
54+
ZSTD_CCtx* cctx = ZSTD_createCCtx();
55+
FUZZ_ASSERT(cctx);
56+
57+
const size_t seqsCapacity = FUZZ_dataProducer_uint32Range(producer, 0, 2 * ZSTD_sequenceBound(size));
58+
ZSTD_Sequence* seqs = (ZSTD_Sequence*)FUZZ_malloc(sizeof(ZSTD_Sequence) * seqsCapacity);
59+
FUZZ_ASSERT(seqsCapacity == 0 || seqs);
60+
61+
FUZZ_setRandomParameters(cctx, size, producer);
62+
FUZZ_ZASSERT(ZSTD_CCtx_setParameter(cctx, ZSTD_c_targetCBlockSize, 0));
63+
FUZZ_ZASSERT(ZSTD_CCtx_setParameter(cctx, ZSTD_c_nbWorkers, 0));
64+
65+
const size_t nbSeqs = ZSTD_generateSequences(cctx, seqs, seqsCapacity, data, size);
66+
if (ZSTD_isError(nbSeqs)) {
67+
/* Allowed to error if the destination is too small */
68+
if (ZSTD_getErrorCode(nbSeqs) == ZSTD_error_dstSize_tooSmall) {
69+
FUZZ_ASSERT(seqsCapacity < ZSTD_sequenceBound(size));
70+
}
71+
} else {
72+
/* Ensure we round trip with and without block delimiters*/
73+
74+
FUZZ_ZASSERT(ZSTD_CCtx_setParameter(cctx, ZSTD_c_blockDelimiters, ZSTD_sf_explicitBlockDelimiters));
75+
testRoundTrip(cctx, seqs, nbSeqs, data, size);
76+
77+
const size_t nbMergedSeqs = ZSTD_mergeBlockDelimiters(seqs, nbSeqs);
78+
FUZZ_ASSERT(nbMergedSeqs <= nbSeqs);
79+
FUZZ_ZASSERT(ZSTD_CCtx_reset(cctx, ZSTD_reset_session_only));
80+
FUZZ_ZASSERT(ZSTD_CCtx_setParameter(cctx, ZSTD_c_blockDelimiters, ZSTD_sf_noBlockDelimiters));
81+
testRoundTrip(cctx, seqs, nbMergedSeqs, data, size);
82+
}
83+
84+
free(seqs);
85+
ZSTD_freeCCtx(cctx);
86+
FUZZ_dataProducer_free(producer);
87+
return 0;
88+
}

0 commit comments

Comments
 (0)