Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/lib/compress/zstd_compress.c b/lib/compress/zstd_compress.c
index 307478e0..a854a9b6 100644
--- a/lib/compress/zstd_compress.c
+++ b/lib/compress/zstd_compress.c
@@ -1108,6 +1108,16 @@ static size_t ZSTD_resetCCtx_usingCDict(ZSTD_CCtx* cctx,
/* Copy only compression parameters related to tables. */
params.cParams = cdict->cParams;
if (windowLog) params.cParams.windowLog = windowLog;
+ /* When searchLength <= 3, hashLog3 = MIN(ZSTD_HASHLOG3_MAX, windowLog).
+ * Increasing windowLog beyond cdict's windowLog would increase hashLog3,
+ * causing the table copy to read past cdict's allocated tables.
+ * Therefore, cap windowLog to not exceed cdict's hashLog3. */
+ if (params.cParams.searchLength <= 3) {
+ U32 const hashLog3 = MIN(ZSTD_HASHLOG3_MAX, params.cParams.windowLog);
+ U32 const cdict_hashLog3 = cdict->matchState.hashLog3;
+ if (hashLog3 > cdict_hashLog3) {
+ params.cParams.windowLog = cdict_hashLog3;
+ } }
params.fParams = fParams;
ZSTD_resetCCtx_internal(cctx, params, pledgedSrcSize,
ZSTDcrp_noMemset, zbuff);
@@ -1168,6 +1178,14 @@ static size_t ZSTD_copyCCtx_internal(ZSTD_CCtx* dstCCtx,
/* Copy only compression parameters related to tables. */
params.cParams = srcCCtx->appliedParams.cParams;
if (windowLog) params.cParams.windowLog = windowLog;
+ /* cap windowLog to not exceed srcCCtx's hashLog3,
+ * to avoid reading/writing beyond table bounds */
+ if (params.cParams.searchLength <= 3) {
+ U32 const hashLog3 = MIN(ZSTD_HASHLOG3_MAX, params.cParams.windowLog);
+ U32 const src_hashLog3 = srcCCtx->blockState.matchState.hashLog3;
+ if (hashLog3 > src_hashLog3) {
+ params.cParams.windowLog = src_hashLog3;
+ } }
params.fParams = fParams;
ZSTD_resetCCtx_internal(dstCCtx, params, pledgedSrcSize,
ZSTDcrp_noMemset, zbuff);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"org": "facebook", "repo": "zstd", "number": 1008, "valid": true, "error_msg": "", "fixed_tests": {"testOrder": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "testInvalid": {"run": "PASS", "test": "NONE", "fix": "PASS"}}, "p2p_tests": {}, "f2p_tests": {}, "s2p_tests": {}, "n2p_tests": {"testOrder": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "testInvalid": {"run": "PASS", "test": "NONE", "fix": "PASS"}}, "run_result": {"passed_count": 2, "failed_count": 0, "skipped_count": 0, "passed_tests": ["testOrder", "testInvalid"], "failed_tests": [], "skipped_tests": []}, "test_patch_result": {"passed_count": 0, "failed_count": 0, "skipped_count": 0, "passed_tests": [], "failed_tests": [], "skipped_tests": []}, "fix_patch_result": {"passed_count": 2, "failed_count": 0, "skipped_count": 0, "passed_tests": ["testOrder", "testInvalid"], "failed_tests": [], "skipped_tests": []}}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/lib/zstd.h b/lib/zstd.h
index 6405da60..1c55a274 100644
--- a/lib/zstd.h
+++ b/lib/zstd.h
@@ -482,7 +482,8 @@ ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t
/*! ZSTD_frameHeaderSize() :
* `src` should point to the start of a ZSTD frame
* `srcSize` must be >= ZSTD_frameHeaderSize_prefix.
-* @return : size of the Frame Header */
+* @return : size of the Frame Header,
+* or an error code, which can be tested with ZSTD_isError() */
ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);


Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"org": "facebook", "repo": "zstd", "number": 1080, "valid": true, "error_msg": "", "fixed_tests": {"testOrder": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "testInvalid": {"run": "PASS", "test": "NONE", "fix": "PASS"}}, "p2p_tests": {}, "f2p_tests": {}, "s2p_tests": {}, "n2p_tests": {"testOrder": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "testInvalid": {"run": "PASS", "test": "NONE", "fix": "PASS"}}, "run_result": {"passed_count": 2, "failed_count": 0, "skipped_count": 0, "passed_tests": ["testOrder", "testInvalid"], "failed_tests": [], "skipped_tests": []}, "test_patch_result": {"passed_count": 0, "failed_count": 0, "skipped_count": 0, "passed_tests": [], "failed_tests": [], "skipped_tests": []}, "fix_patch_result": {"passed_count": 2, "failed_count": 0, "skipped_count": 0, "passed_tests": ["testOrder", "testInvalid"], "failed_tests": [], "skipped_tests": []}}
Loading
Loading