multi_compress 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -3
- data/GET_STARTED.md +3 -3
- data/README.md +75 -66
- data/THIRD_PARTY_NOTICES.md +24 -0
- data/ext/multi_compress/brotli_dec_static_init.c +3 -0
- data/ext/multi_compress/brotli_enc_static_init.c +3 -0
- data/ext/multi_compress/extconf.rb +22 -1
- data/ext/multi_compress/multi_compress.c +152 -72
- data/ext/multi_compress/vendor/.vendored +2 -2
- data/ext/multi_compress/vendor/brotli/LICENSE +19 -0
- data/ext/multi_compress/vendor/brotli/c/common/constants.c +7 -7
- data/ext/multi_compress/vendor/brotli/c/common/constants.h +2 -5
- data/ext/multi_compress/vendor/brotli/c/common/context.c +2 -2
- data/ext/multi_compress/vendor/brotli/c/common/context.h +1 -2
- data/ext/multi_compress/vendor/brotli/c/common/dictionary.c +4 -5856
- data/ext/multi_compress/vendor/brotli/c/common/dictionary.h +1 -2
- data/ext/multi_compress/vendor/brotli/c/common/dictionary_inc.h +5847 -0
- data/ext/multi_compress/vendor/brotli/c/common/platform.c +0 -4
- data/ext/multi_compress/vendor/brotli/c/common/platform.h +182 -43
- data/ext/multi_compress/vendor/brotli/c/common/shared_dictionary.c +3 -7
- data/ext/multi_compress/vendor/brotli/c/common/shared_dictionary_internal.h +1 -1
- data/ext/multi_compress/vendor/brotli/c/common/static_init.h +56 -0
- data/ext/multi_compress/vendor/brotli/c/common/transform.c +6 -4
- data/ext/multi_compress/vendor/brotli/c/common/transform.h +1 -2
- data/ext/multi_compress/vendor/brotli/c/common/version.h +3 -3
- data/ext/multi_compress/vendor/brotli/c/dec/bit_reader.c +2 -3
- data/ext/multi_compress/vendor/brotli/c/dec/bit_reader.h +0 -4
- data/ext/multi_compress/vendor/brotli/c/dec/decode.c +128 -39
- data/ext/multi_compress/vendor/brotli/c/dec/huffman.c +2 -5
- data/ext/multi_compress/vendor/brotli/c/dec/huffman.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/dec/prefix.c +67 -0
- data/ext/multi_compress/vendor/brotli/c/dec/prefix.h +18 -708
- data/ext/multi_compress/vendor/brotli/c/dec/prefix_inc.h +707 -0
- data/ext/multi_compress/vendor/brotli/c/dec/state.c +18 -15
- data/ext/multi_compress/vendor/brotli/c/dec/state.h +2 -6
- data/ext/multi_compress/vendor/brotli/c/dec/static_init.c +53 -0
- data/ext/multi_compress/vendor/brotli/c/dec/static_init.h +30 -0
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references.c +32 -8
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references.h +1 -5
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references_hq.c +15 -15
- data/ext/multi_compress/vendor/brotli/c/enc/backward_references_hq.h +1 -5
- data/ext/multi_compress/vendor/brotli/c/enc/bit_cost.c +28 -4
- data/ext/multi_compress/vendor/brotli/c/enc/bit_cost.h +8 -40
- data/ext/multi_compress/vendor/brotli/c/enc/bit_cost_inc.h +1 -1
- data/ext/multi_compress/vendor/brotli/c/enc/block_splitter.c +9 -12
- data/ext/multi_compress/vendor/brotli/c/enc/block_splitter.h +0 -3
- data/ext/multi_compress/vendor/brotli/c/enc/block_splitter_inc.h +14 -8
- data/ext/multi_compress/vendor/brotli/c/enc/brotli_bit_stream.c +10 -9
- data/ext/multi_compress/vendor/brotli/c/enc/brotli_bit_stream.h +0 -6
- data/ext/multi_compress/vendor/brotli/c/enc/cluster.c +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/cluster.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/command.c +1 -1
- data/ext/multi_compress/vendor/brotli/c/enc/command.h +8 -10
- data/ext/multi_compress/vendor/brotli/c/enc/compound_dictionary.c +3 -5
- data/ext/multi_compress/vendor/brotli/c/enc/compound_dictionary.h +1 -4
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment.c +3 -13
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment_two_pass.c +5 -15
- data/ext/multi_compress/vendor/brotli/c/enc/compress_fragment_two_pass.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash.c +127 -1830
- data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash.h +23 -3
- data/ext/multi_compress/vendor/brotli/c/enc/dictionary_hash_inc.h +1829 -0
- data/ext/multi_compress/vendor/brotli/c/enc/encode.c +77 -52
- data/ext/multi_compress/vendor/brotli/c/enc/encoder_dict.c +9 -7
- data/ext/multi_compress/vendor/brotli/c/enc/encoder_dict.h +2 -4
- data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode.c +3 -6
- data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode.h +2 -4
- data/ext/multi_compress/vendor/brotli/c/enc/entropy_encode_static.h +18 -12
- data/ext/multi_compress/vendor/brotli/c/enc/fast_log.c +1 -1
- data/ext/multi_compress/vendor/brotli/c/enc/fast_log.h +2 -3
- data/ext/multi_compress/vendor/brotli/c/enc/find_match_length.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/hash.h +38 -31
- data/ext/multi_compress/vendor/brotli/c/enc/hash_base.h +38 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +11 -1
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match64_inc.h +24 -7
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match64_simd_inc.h +304 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_inc.h +30 -11
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +4 -0
- data/ext/multi_compress/vendor/brotli/c/enc/hash_longest_match_simd_inc.h +278 -0
- data/ext/multi_compress/vendor/brotli/c/enc/histogram.c +1 -0
- data/ext/multi_compress/vendor/brotli/c/enc/histogram.h +0 -4
- data/ext/multi_compress/vendor/brotli/c/enc/literal_cost.c +4 -6
- data/ext/multi_compress/vendor/brotli/c/enc/literal_cost.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/matching_tag_mask.h +69 -0
- data/ext/multi_compress/vendor/brotli/c/enc/memory.c +0 -5
- data/ext/multi_compress/vendor/brotli/c/enc/memory.h +0 -4
- data/ext/multi_compress/vendor/brotli/c/enc/metablock.c +7 -9
- data/ext/multi_compress/vendor/brotli/c/enc/metablock.h +3 -3
- data/ext/multi_compress/vendor/brotli/c/enc/metablock_inc.h +4 -4
- data/ext/multi_compress/vendor/brotli/c/enc/params.h +0 -1
- data/ext/multi_compress/vendor/brotli/c/enc/prefix.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/quality.h +17 -10
- data/ext/multi_compress/vendor/brotli/c/enc/ringbuffer.h +1 -4
- data/ext/multi_compress/vendor/brotli/c/enc/state.h +2 -2
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict.c +5 -11
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict.h +1 -3
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut.c +224 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut.h +20 -5837
- data/ext/multi_compress/vendor/brotli/c/enc/static_dict_lut_inc.h +5830 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_init.c +59 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_init.h +30 -0
- data/ext/multi_compress/vendor/brotli/c/enc/static_init_lazy.cc +26 -0
- data/ext/multi_compress/vendor/brotli/c/enc/utf8_util.c +1 -1
- data/ext/multi_compress/vendor/brotli/c/enc/utf8_util.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/enc/write_bits.h +0 -2
- data/ext/multi_compress/vendor/brotli/c/include/brotli/decode.h +1 -1
- data/ext/multi_compress/vendor/brotli/c/include/brotli/encode.h +5 -1
- data/ext/multi_compress/vendor/brotli/c/include/brotli/port.h +4 -7
- data/ext/multi_compress/vendor/brotli/c/include/brotli/types.h +2 -2
- data/ext/multi_compress/vendor/lz4/LICENSE +12 -0
- data/ext/multi_compress/vendor/zstd/COPYING +339 -0
- data/ext/multi_compress/vendor/zstd/LICENSE +30 -0
- data/ext/multi_compress/vendor/zstd/lib/Makefile +67 -35
- data/ext/multi_compress/vendor/zstd/lib/README.md +33 -2
- data/ext/multi_compress/vendor/zstd/lib/common/allocations.h +55 -0
- data/ext/multi_compress/vendor/zstd/lib/common/bits.h +205 -0
- data/ext/multi_compress/vendor/zstd/lib/common/bitstream.h +84 -108
- data/ext/multi_compress/vendor/zstd/lib/common/compiler.h +170 -41
- data/ext/multi_compress/vendor/zstd/lib/common/cpu.h +37 -1
- data/ext/multi_compress/vendor/zstd/lib/common/debug.c +7 -1
- data/ext/multi_compress/vendor/zstd/lib/common/debug.h +21 -21
- data/ext/multi_compress/vendor/zstd/lib/common/entropy_common.c +12 -40
- data/ext/multi_compress/vendor/zstd/lib/common/error_private.c +10 -2
- data/ext/multi_compress/vendor/zstd/lib/common/error_private.h +46 -47
- data/ext/multi_compress/vendor/zstd/lib/common/fse.h +8 -100
- data/ext/multi_compress/vendor/zstd/lib/common/fse_decompress.c +28 -116
- data/ext/multi_compress/vendor/zstd/lib/common/huf.h +79 -166
- data/ext/multi_compress/vendor/zstd/lib/common/mem.h +46 -66
- data/ext/multi_compress/vendor/zstd/lib/common/pool.c +27 -11
- data/ext/multi_compress/vendor/zstd/lib/common/pool.h +8 -11
- data/ext/multi_compress/vendor/zstd/lib/common/portability_macros.h +45 -11
- data/ext/multi_compress/vendor/zstd/lib/common/threading.c +74 -14
- data/ext/multi_compress/vendor/zstd/lib/common/threading.h +5 -18
- data/ext/multi_compress/vendor/zstd/lib/common/xxhash.c +5 -11
- data/ext/multi_compress/vendor/zstd/lib/common/xxhash.h +2411 -1003
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_common.c +1 -36
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_deps.h +13 -1
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_internal.h +13 -182
- data/ext/multi_compress/vendor/zstd/lib/common/zstd_trace.h +6 -13
- data/ext/multi_compress/vendor/zstd/lib/compress/clevels.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/fse_compress.c +15 -131
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.c +11 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/hist.h +8 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/huf_compress.c +283 -189
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress.c +2419 -903
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_internal.h +423 -245
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_literals.c +116 -40
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_literals.h +16 -8
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.c +10 -10
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_sequences.h +8 -7
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.c +254 -139
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_compress_superblock.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_cwksp.h +184 -95
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.c +163 -81
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_double_fast.h +18 -14
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.c +507 -197
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_fast.h +7 -14
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.c +579 -484
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_lazy.h +133 -65
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.c +61 -40
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm.h +7 -15
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_ldm_geartab.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.c +352 -218
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_opt.h +37 -21
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_preSplit.c +238 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstd_preSplit.h +33 -0
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.c +239 -175
- data/ext/multi_compress/vendor/zstd/lib/compress/zstdmt_compress.h +5 -16
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress.c +543 -488
- data/ext/multi_compress/vendor/zstd/lib/decompress/huf_decompress_amd64.S +78 -61
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.c +4 -4
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_ddict.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress.c +295 -115
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.c +430 -293
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_block.h +7 -2
- data/ext/multi_compress/vendor/zstd/lib/decompress/zstd_decompress_internal.h +11 -7
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_common.c +1 -1
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_compress.c +1 -1
- data/ext/multi_compress/vendor/zstd/lib/deprecated/zbuff_decompress.c +3 -1
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.c +95 -46
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/cover.h +3 -9
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/divsufsort.h +0 -10
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/fastcover.c +4 -4
- data/ext/multi_compress/vendor/zstd/lib/dictBuilder/zdict.c +25 -97
- data/ext/multi_compress/vendor/zstd/lib/dll/example/Makefile +1 -1
- data/ext/multi_compress/vendor/zstd/lib/dll/example/README.md +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_legacy.h +38 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.c +19 -50
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v01.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.c +27 -80
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v02.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.c +28 -83
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v03.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.c +25 -74
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v04.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.c +31 -76
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v05.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.c +44 -88
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v06.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.c +33 -84
- data/ext/multi_compress/vendor/zstd/lib/legacy/zstd_v07.h +1 -1
- data/ext/multi_compress/vendor/zstd/lib/libzstd.mk +65 -33
- data/ext/multi_compress/vendor/zstd/lib/libzstd.pc.in +5 -5
- data/ext/multi_compress/vendor/zstd/lib/module.modulemap +13 -3
- data/ext/multi_compress/vendor/zstd/lib/zdict.h +65 -36
- data/ext/multi_compress/vendor/zstd/lib/zstd.h +890 -267
- data/ext/multi_compress/vendor/zstd/lib/zstd_errors.h +28 -16
- data/lib/multi_compress/version.rb +1 -1
- metadata +29 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) Yann Collet,
|
|
2
|
+
* Copyright (c) Yann Collet, Meta Platforms, Inc. and affiliates.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
#include <stddef.h> /* size_t, ptrdiff_t */
|
|
13
13
|
#include "zstd_v02.h"
|
|
14
|
+
#include "../common/compiler.h"
|
|
14
15
|
#include "../common/error_private.h"
|
|
15
16
|
|
|
16
17
|
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
low-level memory access routines
|
|
29
30
|
Copyright (C) 2013-2015, Yann Collet.
|
|
30
31
|
|
|
31
|
-
BSD 2-Clause License (
|
|
32
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
32
33
|
|
|
33
34
|
Redistribution and use in source and binary forms, with or without
|
|
34
35
|
modification, are permitted provided that the following conditions are
|
|
@@ -71,20 +72,6 @@ extern "C" {
|
|
|
71
72
|
#include <string.h> /* memcpy */
|
|
72
73
|
|
|
73
74
|
|
|
74
|
-
/******************************************
|
|
75
|
-
* Compiler-specific
|
|
76
|
-
******************************************/
|
|
77
|
-
#if defined(__GNUC__)
|
|
78
|
-
# define MEM_STATIC static __attribute__((unused))
|
|
79
|
-
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
|
80
|
-
# define MEM_STATIC static inline
|
|
81
|
-
#elif defined(_MSC_VER)
|
|
82
|
-
# define MEM_STATIC static __inline
|
|
83
|
-
#else
|
|
84
|
-
# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
|
|
85
|
-
#endif
|
|
86
|
-
|
|
87
|
-
|
|
88
75
|
/****************************************************************
|
|
89
76
|
* Basic Types
|
|
90
77
|
*****************************************************************/
|
|
@@ -115,24 +102,6 @@ extern "C" {
|
|
|
115
102
|
/****************************************************************
|
|
116
103
|
* Memory I/O
|
|
117
104
|
*****************************************************************/
|
|
118
|
-
/* MEM_FORCE_MEMORY_ACCESS
|
|
119
|
-
* By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable.
|
|
120
|
-
* Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal.
|
|
121
|
-
* The below switch allow to select different access method for improved performance.
|
|
122
|
-
* Method 0 (default) : use `memcpy()`. Safe and portable.
|
|
123
|
-
* Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable).
|
|
124
|
-
* This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`.
|
|
125
|
-
* Method 2 : direct access. This method is portable but violate C standard.
|
|
126
|
-
* It can generate buggy code on targets generating assembly depending on alignment.
|
|
127
|
-
* But in some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6)
|
|
128
|
-
* See http://fastcompression.blogspot.fr/2015/08/accessing-unaligned-memory.html for details.
|
|
129
|
-
* Prefer these methods in priority order (0 > 1 > 2)
|
|
130
|
-
*/
|
|
131
|
-
#ifndef MEM_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
|
|
132
|
-
# if defined(__INTEL_COMPILER) || defined(__GNUC__) || defined(__ICCARM__)
|
|
133
|
-
# define MEM_FORCE_MEMORY_ACCESS 1
|
|
134
|
-
# endif
|
|
135
|
-
#endif
|
|
136
105
|
|
|
137
106
|
MEM_STATIC unsigned MEM_32bits(void) { return sizeof(void*)==4; }
|
|
138
107
|
MEM_STATIC unsigned MEM_64bits(void) { return sizeof(void*)==8; }
|
|
@@ -143,33 +112,6 @@ MEM_STATIC unsigned MEM_isLittleEndian(void)
|
|
|
143
112
|
return one.c[0];
|
|
144
113
|
}
|
|
145
114
|
|
|
146
|
-
#if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2)
|
|
147
|
-
|
|
148
|
-
/* violates C standard on structure alignment.
|
|
149
|
-
Only use if no other choice to achieve best performance on target platform */
|
|
150
|
-
MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; }
|
|
151
|
-
MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; }
|
|
152
|
-
MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; }
|
|
153
|
-
|
|
154
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
|
|
155
|
-
|
|
156
|
-
#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1)
|
|
157
|
-
|
|
158
|
-
/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
|
|
159
|
-
/* currently only defined for gcc and icc */
|
|
160
|
-
typedef union { U16 u16; U32 u32; U64 u64; } __attribute__((packed)) unalign;
|
|
161
|
-
|
|
162
|
-
MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign*)ptr)->u16; }
|
|
163
|
-
MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
|
|
164
|
-
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign*)ptr)->u64; }
|
|
165
|
-
|
|
166
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; }
|
|
167
|
-
|
|
168
|
-
#else
|
|
169
|
-
|
|
170
|
-
/* default method, safe and standard.
|
|
171
|
-
can sometimes prove slower */
|
|
172
|
-
|
|
173
115
|
MEM_STATIC U16 MEM_read16(const void* memPtr)
|
|
174
116
|
{
|
|
175
117
|
U16 val; memcpy(&val, memPtr, sizeof(val)); return val;
|
|
@@ -190,9 +132,6 @@ MEM_STATIC void MEM_write16(void* memPtr, U16 value)
|
|
|
190
132
|
memcpy(memPtr, &value, sizeof(value));
|
|
191
133
|
}
|
|
192
134
|
|
|
193
|
-
#endif /* MEM_FORCE_MEMORY_ACCESS */
|
|
194
|
-
|
|
195
|
-
|
|
196
135
|
MEM_STATIC U16 MEM_readLE16(const void* memPtr)
|
|
197
136
|
{
|
|
198
137
|
if (MEM_isLittleEndian())
|
|
@@ -269,7 +208,7 @@ MEM_STATIC size_t MEM_readLEST(const void* memPtr)
|
|
|
269
208
|
header file (to include)
|
|
270
209
|
Copyright (C) 2013-2015, Yann Collet.
|
|
271
210
|
|
|
272
|
-
BSD 2-Clause License (
|
|
211
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
273
212
|
|
|
274
213
|
Redistribution and use in source and binary forms, with or without
|
|
275
214
|
modification, are permitted provided that the following conditions are
|
|
@@ -433,7 +372,7 @@ MEM_STATIC size_t BIT_lookBits(BIT_DStream_t* bitD, U32 nbBits)
|
|
|
433
372
|
}
|
|
434
373
|
|
|
435
374
|
/*! BIT_lookBitsFast :
|
|
436
|
-
* unsafe version; only works
|
|
375
|
+
* unsafe version; only works if nbBits >= 1 */
|
|
437
376
|
MEM_STATIC size_t BIT_lookBitsFast(BIT_DStream_t* bitD, U32 nbBits)
|
|
438
377
|
{
|
|
439
378
|
const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1;
|
|
@@ -453,7 +392,7 @@ MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits)
|
|
|
453
392
|
}
|
|
454
393
|
|
|
455
394
|
/*!BIT_readBitsFast :
|
|
456
|
-
* unsafe version; only works
|
|
395
|
+
* unsafe version; only works if nbBits >= 1 */
|
|
457
396
|
MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits)
|
|
458
397
|
{
|
|
459
398
|
size_t value = BIT_lookBitsFast(bitD, nbBits);
|
|
@@ -510,7 +449,7 @@ MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream)
|
|
|
510
449
|
Error codes and messages
|
|
511
450
|
Copyright (C) 2013-2015, Yann Collet
|
|
512
451
|
|
|
513
|
-
BSD 2-Clause License (
|
|
452
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
514
453
|
|
|
515
454
|
Redistribution and use in source and binary forms, with or without
|
|
516
455
|
modification, are permitted provided that the following conditions are
|
|
@@ -609,7 +548,7 @@ typedef unsigned FSE_DTable; /* don't allocate that. It's just a way to be mor
|
|
|
609
548
|
header file for static linking (only)
|
|
610
549
|
Copyright (C) 2013-2015, Yann Collet
|
|
611
550
|
|
|
612
|
-
BSD 2-Clause License (
|
|
551
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
613
552
|
|
|
614
553
|
Redistribution and use in source and binary forms, with or without
|
|
615
554
|
modification, are permitted provided that the following conditions are
|
|
@@ -753,7 +692,7 @@ MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr)
|
|
|
753
692
|
header file for static linking (only)
|
|
754
693
|
Copyright (C) 2013-2015, Yann Collet
|
|
755
694
|
|
|
756
|
-
BSD 2-Clause License (
|
|
695
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
757
696
|
|
|
758
697
|
Redistribution and use in source and binary forms, with or without
|
|
759
698
|
modification, are permitted provided that the following conditions are
|
|
@@ -822,7 +761,7 @@ static size_t HUF_decompress4X6 (void* dst, size_t dstSize, const void* cSrc, si
|
|
|
822
761
|
Header File
|
|
823
762
|
Copyright (C) 2014-2015, Yann Collet.
|
|
824
763
|
|
|
825
|
-
BSD 2-Clause License (
|
|
764
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
826
765
|
|
|
827
766
|
Redistribution and use in source and binary forms, with or without
|
|
828
767
|
modification, are permitted provided that the following conditions are
|
|
@@ -882,7 +821,7 @@ typedef struct ZSTD_CCtx_s ZSTD_CCtx; /* incomplete type */
|
|
|
882
821
|
Header File for static linking only
|
|
883
822
|
Copyright (C) 2014-2015, Yann Collet.
|
|
884
823
|
|
|
885
|
-
BSD 2-Clause License (
|
|
824
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
886
825
|
|
|
887
826
|
Redistribution and use in source and binary forms, with or without
|
|
888
827
|
modification, are permitted provided that the following conditions are
|
|
@@ -923,7 +862,7 @@ extern "C" {
|
|
|
923
862
|
* Streaming functions
|
|
924
863
|
***************************************/
|
|
925
864
|
|
|
926
|
-
typedef struct
|
|
865
|
+
typedef struct ZSTDv02_Dctx_s ZSTD_DCtx;
|
|
927
866
|
|
|
928
867
|
/*
|
|
929
868
|
Use above functions alternatively.
|
|
@@ -946,7 +885,7 @@ typedef struct ZSTD_DCtx_s ZSTD_DCtx;
|
|
|
946
885
|
FSE : Finite State Entropy coder
|
|
947
886
|
Copyright (C) 2013-2015, Yann Collet.
|
|
948
887
|
|
|
949
|
-
BSD 2-Clause License (
|
|
888
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
950
889
|
|
|
951
890
|
Redistribution and use in source and binary forms, with or without
|
|
952
891
|
modification, are permitted provided that the following conditions are
|
|
@@ -1450,7 +1389,7 @@ static size_t FSE_decompress(void* dst, size_t maxDstSize, const void* cSrc, siz
|
|
|
1450
1389
|
Huff0 : Huffman coder, part of New Generation Entropy library
|
|
1451
1390
|
Copyright (C) 2013-2015, Yann Collet.
|
|
1452
1391
|
|
|
1453
|
-
BSD 2-Clause License (
|
|
1392
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1454
1393
|
|
|
1455
1394
|
Redistribution and use in source and binary forms, with or without
|
|
1456
1395
|
modification, are permitted provided that the following conditions are
|
|
@@ -2609,7 +2548,7 @@ static size_t HUF_decompress (void* dst, size_t dstSize, const void* cSrc, size_
|
|
|
2609
2548
|
zstd - standard compression library
|
|
2610
2549
|
Copyright (C) 2014-2015, Yann Collet.
|
|
2611
2550
|
|
|
2612
|
-
BSD 2-Clause License (
|
|
2551
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
2613
2552
|
|
|
2614
2553
|
Redistribution and use in source and binary forms, with or without
|
|
2615
2554
|
modification, are permitted provided that the following conditions are
|
|
@@ -2783,7 +2722,7 @@ typedef struct {
|
|
|
2783
2722
|
BYTE* matchLength;
|
|
2784
2723
|
BYTE* dumpsStart;
|
|
2785
2724
|
BYTE* dumps;
|
|
2786
|
-
}
|
|
2725
|
+
} SeqStore_t;
|
|
2787
2726
|
|
|
2788
2727
|
|
|
2789
2728
|
/* *************************************
|
|
@@ -2798,7 +2737,7 @@ static unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
|
|
|
2798
2737
|
/* *************************************************************
|
|
2799
2738
|
* Decompression section
|
|
2800
2739
|
***************************************************************/
|
|
2801
|
-
struct
|
|
2740
|
+
struct ZSTDv02_Dctx_s
|
|
2802
2741
|
{
|
|
2803
2742
|
U32 LLTable[FSE_DTABLE_SIZE_U32(LLFSELog)];
|
|
2804
2743
|
U32 OffTable[FSE_DTABLE_SIZE_U32(OffFSELog)];
|
|
@@ -3114,12 +3053,19 @@ static size_t ZSTD_execSequence(BYTE* op,
|
|
|
3114
3053
|
const BYTE* const litEnd = *litPtr + sequence.litLength;
|
|
3115
3054
|
|
|
3116
3055
|
/* checks */
|
|
3117
|
-
|
|
3056
|
+
size_t const seqLength = sequence.litLength + sequence.matchLength;
|
|
3057
|
+
|
|
3058
|
+
if (seqLength > (size_t)(oend - op)) return ERROR(dstSize_tooSmall);
|
|
3059
|
+
if (sequence.litLength > (size_t)(litLimit - *litPtr)) return ERROR(corruption_detected);
|
|
3060
|
+
/* Now we know there are no overflow in literal nor match lengths, can use the pointer check */
|
|
3061
|
+
if (oLitEnd > oend_8) return ERROR(dstSize_tooSmall);
|
|
3062
|
+
if (sequence.offset > (U32)(oLitEnd - base)) return ERROR(corruption_detected);
|
|
3063
|
+
|
|
3118
3064
|
if (oMatchEnd > oend) return ERROR(dstSize_tooSmall); /* overwrite beyond dst buffer */
|
|
3119
3065
|
if (litEnd > litLimit) return ERROR(corruption_detected); /* overRead beyond lit buffer */
|
|
3120
3066
|
|
|
3121
3067
|
/* copy Literals */
|
|
3122
|
-
ZSTD_wildcopy(op, *litPtr, sequence.litLength); /* note : oLitEnd <= oend-8 : no risk of overwrite beyond oend */
|
|
3068
|
+
ZSTD_wildcopy(op, *litPtr, (ptrdiff_t)sequence.litLength); /* note : oLitEnd <= oend-8 : no risk of overwrite beyond oend */
|
|
3123
3069
|
op = oLitEnd;
|
|
3124
3070
|
*litPtr = litEnd; /* update for next sequence */
|
|
3125
3071
|
|
|
@@ -3472,6 +3418,7 @@ static size_t ZSTD_decompressContinue(ZSTD_DCtx* ctx, void* dst, size_t maxDstSi
|
|
|
3472
3418
|
}
|
|
3473
3419
|
ctx->phase = 1;
|
|
3474
3420
|
ctx->expected = ZSTD_blockHeaderSize;
|
|
3421
|
+
if (ZSTD_isError(rSize)) return rSize;
|
|
3475
3422
|
ctx->previousDstEnd = (void*)( ((char*)dst) + rSize);
|
|
3476
3423
|
return rSize;
|
|
3477
3424
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) Yann Collet,
|
|
2
|
+
* Copyright (c) Yann Collet, Meta Platforms, Inc. and affiliates.
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
#include <stddef.h> /* size_t, ptrdiff_t */
|
|
13
13
|
#include "zstd_v03.h"
|
|
14
|
+
#include "../common/compiler.h"
|
|
14
15
|
#include "../common/error_private.h"
|
|
15
16
|
|
|
16
17
|
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
low-level memory access routines
|
|
30
31
|
Copyright (C) 2013-2015, Yann Collet.
|
|
31
32
|
|
|
32
|
-
BSD 2-Clause License (
|
|
33
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
33
34
|
|
|
34
35
|
Redistribution and use in source and binary forms, with or without
|
|
35
36
|
modification, are permitted provided that the following conditions are
|
|
@@ -72,20 +73,6 @@ extern "C" {
|
|
|
72
73
|
#include <string.h> /* memcpy */
|
|
73
74
|
|
|
74
75
|
|
|
75
|
-
/******************************************
|
|
76
|
-
* Compiler-specific
|
|
77
|
-
******************************************/
|
|
78
|
-
#if defined(__GNUC__)
|
|
79
|
-
# define MEM_STATIC static __attribute__((unused))
|
|
80
|
-
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
|
81
|
-
# define MEM_STATIC static inline
|
|
82
|
-
#elif defined(_MSC_VER)
|
|
83
|
-
# define MEM_STATIC static __inline
|
|
84
|
-
#else
|
|
85
|
-
# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
|
|
86
|
-
#endif
|
|
87
|
-
|
|
88
|
-
|
|
89
76
|
/****************************************************************
|
|
90
77
|
* Basic Types
|
|
91
78
|
*****************************************************************/
|
|
@@ -116,24 +103,6 @@ extern "C" {
|
|
|
116
103
|
/****************************************************************
|
|
117
104
|
* Memory I/O
|
|
118
105
|
*****************************************************************/
|
|
119
|
-
/* MEM_FORCE_MEMORY_ACCESS
|
|
120
|
-
* By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable.
|
|
121
|
-
* Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal.
|
|
122
|
-
* The below switch allow to select different access method for improved performance.
|
|
123
|
-
* Method 0 (default) : use `memcpy()`. Safe and portable.
|
|
124
|
-
* Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable).
|
|
125
|
-
* This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`.
|
|
126
|
-
* Method 2 : direct access. This method is portable but violate C standard.
|
|
127
|
-
* It can generate buggy code on targets generating assembly depending on alignment.
|
|
128
|
-
* But in some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6)
|
|
129
|
-
* See http://fastcompression.blogspot.fr/2015/08/accessing-unaligned-memory.html for details.
|
|
130
|
-
* Prefer these methods in priority order (0 > 1 > 2)
|
|
131
|
-
*/
|
|
132
|
-
#ifndef MEM_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
|
|
133
|
-
# if defined(__INTEL_COMPILER) || defined(__GNUC__) || defined(__ICCARM__)
|
|
134
|
-
# define MEM_FORCE_MEMORY_ACCESS 1
|
|
135
|
-
# endif
|
|
136
|
-
#endif
|
|
137
106
|
|
|
138
107
|
MEM_STATIC unsigned MEM_32bits(void) { return sizeof(void*)==4; }
|
|
139
108
|
MEM_STATIC unsigned MEM_64bits(void) { return sizeof(void*)==8; }
|
|
@@ -144,33 +113,6 @@ MEM_STATIC unsigned MEM_isLittleEndian(void)
|
|
|
144
113
|
return one.c[0];
|
|
145
114
|
}
|
|
146
115
|
|
|
147
|
-
#if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2)
|
|
148
|
-
|
|
149
|
-
/* violates C standard on structure alignment.
|
|
150
|
-
Only use if no other choice to achieve best performance on target platform */
|
|
151
|
-
MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; }
|
|
152
|
-
MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; }
|
|
153
|
-
MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; }
|
|
154
|
-
|
|
155
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
|
|
156
|
-
|
|
157
|
-
#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1)
|
|
158
|
-
|
|
159
|
-
/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
|
|
160
|
-
/* currently only defined for gcc and icc */
|
|
161
|
-
typedef union { U16 u16; U32 u32; U64 u64; } __attribute__((packed)) unalign;
|
|
162
|
-
|
|
163
|
-
MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign*)ptr)->u16; }
|
|
164
|
-
MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
|
|
165
|
-
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign*)ptr)->u64; }
|
|
166
|
-
|
|
167
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; }
|
|
168
|
-
|
|
169
|
-
#else
|
|
170
|
-
|
|
171
|
-
/* default method, safe and standard.
|
|
172
|
-
can sometimes prove slower */
|
|
173
|
-
|
|
174
116
|
MEM_STATIC U16 MEM_read16(const void* memPtr)
|
|
175
117
|
{
|
|
176
118
|
U16 val; memcpy(&val, memPtr, sizeof(val)); return val;
|
|
@@ -191,10 +133,6 @@ MEM_STATIC void MEM_write16(void* memPtr, U16 value)
|
|
|
191
133
|
memcpy(memPtr, &value, sizeof(value));
|
|
192
134
|
}
|
|
193
135
|
|
|
194
|
-
|
|
195
|
-
#endif /* MEM_FORCE_MEMORY_ACCESS */
|
|
196
|
-
|
|
197
|
-
|
|
198
136
|
MEM_STATIC U16 MEM_readLE16(const void* memPtr)
|
|
199
137
|
{
|
|
200
138
|
if (MEM_isLittleEndian())
|
|
@@ -271,7 +209,7 @@ MEM_STATIC size_t MEM_readLEST(const void* memPtr)
|
|
|
271
209
|
header file (to include)
|
|
272
210
|
Copyright (C) 2013-2015, Yann Collet.
|
|
273
211
|
|
|
274
|
-
BSD 2-Clause License (
|
|
212
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
275
213
|
|
|
276
214
|
Redistribution and use in source and binary forms, with or without
|
|
277
215
|
modification, are permitted provided that the following conditions are
|
|
@@ -435,7 +373,7 @@ MEM_STATIC size_t BIT_lookBits(BIT_DStream_t* bitD, U32 nbBits)
|
|
|
435
373
|
}
|
|
436
374
|
|
|
437
375
|
/*! BIT_lookBitsFast :
|
|
438
|
-
* unsafe version; only works
|
|
376
|
+
* unsafe version; only works if nbBits >= 1 */
|
|
439
377
|
MEM_STATIC size_t BIT_lookBitsFast(BIT_DStream_t* bitD, U32 nbBits)
|
|
440
378
|
{
|
|
441
379
|
const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1;
|
|
@@ -455,7 +393,7 @@ MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits)
|
|
|
455
393
|
}
|
|
456
394
|
|
|
457
395
|
/*!BIT_readBitsFast :
|
|
458
|
-
* unsafe version; only works
|
|
396
|
+
* unsafe version; only works if nbBits >= 1 */
|
|
459
397
|
MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits)
|
|
460
398
|
{
|
|
461
399
|
size_t value = BIT_lookBitsFast(bitD, nbBits);
|
|
@@ -512,7 +450,7 @@ MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream)
|
|
|
512
450
|
Error codes and messages
|
|
513
451
|
Copyright (C) 2013-2015, Yann Collet
|
|
514
452
|
|
|
515
|
-
BSD 2-Clause License (
|
|
453
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
516
454
|
|
|
517
455
|
Redistribution and use in source and binary forms, with or without
|
|
518
456
|
modification, are permitted provided that the following conditions are
|
|
@@ -611,7 +549,7 @@ typedef unsigned FSE_DTable; /* don't allocate that. It's just a way to be mor
|
|
|
611
549
|
header file for static linking (only)
|
|
612
550
|
Copyright (C) 2013-2015, Yann Collet
|
|
613
551
|
|
|
614
|
-
BSD 2-Clause License (
|
|
552
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
615
553
|
|
|
616
554
|
Redistribution and use in source and binary forms, with or without
|
|
617
555
|
modification, are permitted provided that the following conditions are
|
|
@@ -755,7 +693,7 @@ MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr)
|
|
|
755
693
|
header file for static linking (only)
|
|
756
694
|
Copyright (C) 2013-2015, Yann Collet
|
|
757
695
|
|
|
758
|
-
BSD 2-Clause License (
|
|
696
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
759
697
|
|
|
760
698
|
Redistribution and use in source and binary forms, with or without
|
|
761
699
|
modification, are permitted provided that the following conditions are
|
|
@@ -823,7 +761,7 @@ static size_t HUF_decompress4X4 (void* dst, size_t dstSize, const void* cSrc, si
|
|
|
823
761
|
Header File
|
|
824
762
|
Copyright (C) 2014-2015, Yann Collet.
|
|
825
763
|
|
|
826
|
-
BSD 2-Clause License (
|
|
764
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
827
765
|
|
|
828
766
|
Redistribution and use in source and binary forms, with or without
|
|
829
767
|
modification, are permitted provided that the following conditions are
|
|
@@ -883,7 +821,7 @@ typedef struct ZSTD_CCtx_s ZSTD_CCtx; /* incomplete type */
|
|
|
883
821
|
Header File for static linking only
|
|
884
822
|
Copyright (C) 2014-2015, Yann Collet.
|
|
885
823
|
|
|
886
|
-
BSD 2-Clause License (
|
|
824
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
887
825
|
|
|
888
826
|
Redistribution and use in source and binary forms, with or without
|
|
889
827
|
modification, are permitted provided that the following conditions are
|
|
@@ -924,7 +862,7 @@ extern "C" {
|
|
|
924
862
|
* Streaming functions
|
|
925
863
|
***************************************/
|
|
926
864
|
|
|
927
|
-
typedef struct
|
|
865
|
+
typedef struct ZSTDv03_Dctx_s ZSTD_DCtx;
|
|
928
866
|
|
|
929
867
|
/*
|
|
930
868
|
Use above functions alternatively.
|
|
@@ -947,7 +885,7 @@ typedef struct ZSTD_DCtx_s ZSTD_DCtx;
|
|
|
947
885
|
FSE : Finite State Entropy coder
|
|
948
886
|
Copyright (C) 2013-2015, Yann Collet.
|
|
949
887
|
|
|
950
|
-
BSD 2-Clause License (
|
|
888
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
951
889
|
|
|
952
890
|
Redistribution and use in source and binary forms, with or without
|
|
953
891
|
modification, are permitted provided that the following conditions are
|
|
@@ -1451,7 +1389,7 @@ static size_t FSE_decompress(void* dst, size_t maxDstSize, const void* cSrc, siz
|
|
|
1451
1389
|
Huff0 : Huffman coder, part of New Generation Entropy library
|
|
1452
1390
|
Copyright (C) 2013-2015, Yann Collet.
|
|
1453
1391
|
|
|
1454
|
-
BSD 2-Clause License (
|
|
1392
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
1455
1393
|
|
|
1456
1394
|
Redistribution and use in source and binary forms, with or without
|
|
1457
1395
|
modification, are permitted provided that the following conditions are
|
|
@@ -2248,7 +2186,7 @@ static size_t HUF_decompress (void* dst, size_t dstSize, const void* cSrc, size_
|
|
|
2248
2186
|
zstd - standard compression library
|
|
2249
2187
|
Copyright (C) 2014-2015, Yann Collet.
|
|
2250
2188
|
|
|
2251
|
-
BSD 2-Clause License (
|
|
2189
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
|
2252
2190
|
|
|
2253
2191
|
Redistribution and use in source and binary forms, with or without
|
|
2254
2192
|
modification, are permitted provided that the following conditions are
|
|
@@ -2424,7 +2362,7 @@ typedef struct {
|
|
|
2424
2362
|
BYTE* matchLength;
|
|
2425
2363
|
BYTE* dumpsStart;
|
|
2426
2364
|
BYTE* dumps;
|
|
2427
|
-
}
|
|
2365
|
+
} SeqStore_t;
|
|
2428
2366
|
|
|
2429
2367
|
|
|
2430
2368
|
/* *************************************
|
|
@@ -2439,7 +2377,7 @@ static unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
|
|
|
2439
2377
|
/* *************************************************************
|
|
2440
2378
|
* Decompression section
|
|
2441
2379
|
***************************************************************/
|
|
2442
|
-
struct
|
|
2380
|
+
struct ZSTDv03_Dctx_s
|
|
2443
2381
|
{
|
|
2444
2382
|
U32 LLTable[FSE_DTABLE_SIZE_U32(LLFSELog)];
|
|
2445
2383
|
U32 OffTable[FSE_DTABLE_SIZE_U32(OffFSELog)];
|
|
@@ -2755,18 +2693,24 @@ static size_t ZSTD_execSequence(BYTE* op,
|
|
|
2755
2693
|
const BYTE* const litEnd = *litPtr + sequence.litLength;
|
|
2756
2694
|
|
|
2757
2695
|
/* checks */
|
|
2758
|
-
|
|
2696
|
+
size_t const seqLength = sequence.litLength + sequence.matchLength;
|
|
2697
|
+
|
|
2698
|
+
if (seqLength > (size_t)(oend - op)) return ERROR(dstSize_tooSmall);
|
|
2699
|
+
if (sequence.litLength > (size_t)(litLimit - *litPtr)) return ERROR(corruption_detected);
|
|
2700
|
+
/* Now we know there are no overflow in literal nor match lengths, can use pointer checks */
|
|
2701
|
+
if (oLitEnd > oend_8) return ERROR(dstSize_tooSmall);
|
|
2702
|
+
if (sequence.offset > (U32)(oLitEnd - base)) return ERROR(corruption_detected);
|
|
2703
|
+
|
|
2759
2704
|
if (oMatchEnd > oend) return ERROR(dstSize_tooSmall); /* overwrite beyond dst buffer */
|
|
2760
2705
|
if (litEnd > litLimit) return ERROR(corruption_detected); /* overRead beyond lit buffer */
|
|
2761
2706
|
|
|
2762
2707
|
/* copy Literals */
|
|
2763
|
-
ZSTD_wildcopy(op, *litPtr, sequence.litLength); /* note : oLitEnd <= oend-8 : no risk of overwrite beyond oend */
|
|
2708
|
+
ZSTD_wildcopy(op, *litPtr, (ptrdiff_t)sequence.litLength); /* note : oLitEnd <= oend-8 : no risk of overwrite beyond oend */
|
|
2764
2709
|
op = oLitEnd;
|
|
2765
2710
|
*litPtr = litEnd; /* update for next sequence */
|
|
2766
2711
|
|
|
2767
2712
|
/* copy Match */
|
|
2768
|
-
{
|
|
2769
|
-
const BYTE* match = op - sequence.offset;
|
|
2713
|
+
{ const BYTE* match = op - sequence.offset;
|
|
2770
2714
|
|
|
2771
2715
|
/* check */
|
|
2772
2716
|
if (sequence.offset > (size_t)op) return ERROR(corruption_detected); /* address space overflow test (this test seems kept by clang optimizer) */
|
|
@@ -3114,6 +3058,7 @@ static size_t ZSTD_decompressContinue(ZSTD_DCtx* ctx, void* dst, size_t maxDstSi
|
|
|
3114
3058
|
}
|
|
3115
3059
|
ctx->phase = 1;
|
|
3116
3060
|
ctx->expected = ZSTD_blockHeaderSize;
|
|
3061
|
+
if (ZSTD_isError(rSize)) return rSize;
|
|
3117
3062
|
ctx->previousDstEnd = (void*)( ((char*)dst) + rSize);
|
|
3118
3063
|
return rSize;
|
|
3119
3064
|
}
|