Modification to offset validation to include entire sequence
diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c
index 069835b..fbd4a80 100644
--- a/lib/compress/zstd_compress.c
+++ b/lib/compress/zstd_compress.c
@@ -4561,11 +4561,10 @@
updatedRepcodes = ZSTD_updateRep(updatedRepcodes.rep, offCode, ll0);
DEBUGLOG(6, "Storing sequence: (of: %u, ml: %u, ll: %u)", offCode, matchLength, litLength);
- seqPos->posInSrc += litLength;
+ seqPos->posInSrc += litLength + matchLength;
FORWARD_IF_ERROR(ZSTD_validateSequence(offCode, matchLength, seqPos->posInSrc,
cctx->appliedParams.cParams.windowLog, dictSize),
"Sequence validation failed");
- seqPos->posInSrc += matchLength;
ZSTD_storeSeq(seqStore, litLength, ip, iend, offCode, matchLength - MINMATCH);
ip += matchLength + litLength;
}
@@ -4682,11 +4681,10 @@
updatedRepcodes = ZSTD_updateRep(updatedRepcodes.rep, offCode, ll0);
}
- seqPos->posInSrc += litLength;
+ seqPos->posInSrc += litLength + matchLength;
FORWARD_IF_ERROR(ZSTD_validateSequence(offCode, matchLength, seqPos->posInSrc,
cctx->appliedParams.cParams.windowLog, dictSize),
"Sequence validation failed");
- seqPos->posInSrc += matchLength;
DEBUGLOG(6, "Storing sequence: (of: %u, ml: %u, ll: %u)", offCode, matchLength, litLength);
ZSTD_storeSeq(seqStore, litLength, ip, iend, offCode, matchLength - MINMATCH);
ip += matchLength + litLength;
diff --git a/tests/fuzz/sequence_compression_api b/tests/fuzz/sequence_compression_api
new file mode 100755
index 0000000..7ff7f55
--- /dev/null
+++ b/tests/fuzz/sequence_compression_api
Binary files differ