fix-a-determinism-bug-with-the-DUBT

This commit is contained in:
hadson 2021-11-24 09:41:41 +08:00
parent 2a19c4bba3
commit fc8bd62222
2 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,39 @@
diff -Nur zstd-1.5.0/lib/compress/zstd_compress_internal.h new-zstd/lib/compress/zstd_compress_internal.h
--- zstd-1.5.0/lib/compress/zstd_compress_internal.h 2021-05-14 22:59:34.000000000 +0800
+++ new-zstd/lib/compress/zstd_compress_internal.h 2021-11-22 20:00:33.612480981 +0800
@@ -199,6 +199,8 @@
*/
} ZSTD_window_t;
+#define ZSTD_WINDOW_START_INDEX 2
+
typedef struct ZSTD_matchState_t ZSTD_matchState_t;
#define ZSTD_ROW_HASH_CACHE_SIZE 8 /* Size of prefetching hash cache for row-based matchfinder */
@@ -884,9 +886,9 @@
MEM_STATIC U32 ZSTD_window_isEmpty(ZSTD_window_t const window)
{
- return window.dictLimit == 1 &&
- window.lowLimit == 1 &&
- (window.nextSrc - window.base) == 1;
+ return window.dictLimit == ZSTD_WINDOW_START_INDEX &&
+ window.lowLimit == ZSTD_WINDOW_START_INDEX &&
+ (window.nextSrc - window.base) == ZSTD_WINDOW_START_INDEX;
}
/**
@@ -1151,9 +1153,10 @@
ZSTD_memset(window, 0, sizeof(*window));
window->base = (BYTE const*)"";
window->dictBase = (BYTE const*)"";
- window->dictLimit = 1; /* start from 1, so that 1st position is valid */
- window->lowLimit = 1; /* it ensures first and later CCtx usages compress the same */
- window->nextSrc = window->base + 1; /* see issue #1241 */
+ ZSTD_STATIC_ASSERT(ZSTD_DUBT_UNSORTED_MARK < ZSTD_WINDOW_START_INDEX);
+ window->dictLimit = ZSTD_WINDOW_START_INDEX; /* start from >0, so that 1st position is valid */
+ window->lowLimit = ZSTD_WINDOW_START_INDEX; /* it ensures first and later CCtx usages compress the same */
+ window->nextSrc = window->base + ZSTD_WINDOW_START_INDEX; /* see issue #1241 */
window->nbOverflowCorrections = 0;
}

View File

@ -2,7 +2,7 @@
Name: zstd
Version: 1.5.0
Release: 8
Release: 9
Summary: A fast lossless compression algorithm
License: BSD and GPLv2
URL: https://github.com/facebook/zstd
@ -13,6 +13,7 @@ Patch2: backport-zstd-1.5.0-patch-2-add-tests-set-mtime-on-output-files
Patch3: backport-zstd-1.5.0-patch-3-remove-invalid-test.patch
Patch4: backport-zstd-1.5.0-patch-4-limit-train-samples.patch
Patch5: patch-5-add-test-case-survive-a-list-of-files-which-long-file-name-length.patch
Patch6: backport-zstd-1.5.0-patch-6-fix-a-determinism-bug-with-the-DUBT.patch
BuildRequires: gtest-devel gcc-c++ pkg-config
@ -91,6 +92,9 @@ install -D -m644 programs/zstd.1 %{buildroot}%{_mandir}/man1/pzstd.1
%{_mandir}/man1/*.1*
%changelog
* Mon Nov 22 2021 wangshenglong <wangshenglong7@hauwei.com> - 1.5.0.9
* fix a determinism bug with the DUBT
* Thu Nov 18 2021 zhangxiao <zhangxiao131@huawei.com> - 1.5.0.8
* add test case survive a list of files which long file name length