extzstd 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/contrib/zstd/CHANGELOG +188 -1
- data/contrib/zstd/CONTRIBUTING.md +157 -74
- data/contrib/zstd/LICENSE +4 -4
- data/contrib/zstd/Makefile +81 -58
- data/contrib/zstd/Package.swift +36 -0
- data/contrib/zstd/README.md +59 -35
- data/contrib/zstd/TESTING.md +2 -3
- data/contrib/zstd/appveyor.yml +49 -136
- data/contrib/zstd/lib/BUCK +5 -7
- data/contrib/zstd/lib/Makefile +87 -181
- data/contrib/zstd/lib/README.md +23 -6
- data/contrib/zstd/lib/common/allocations.h +55 -0
- data/contrib/zstd/lib/common/bits.h +200 -0
- data/contrib/zstd/lib/common/bitstream.h +33 -59
- data/contrib/zstd/lib/common/compiler.h +115 -45
- data/contrib/zstd/lib/common/cpu.h +1 -1
- data/contrib/zstd/lib/common/debug.c +1 -1
- data/contrib/zstd/lib/common/debug.h +1 -1
- data/contrib/zstd/lib/common/entropy_common.c +15 -37
- data/contrib/zstd/lib/common/error_private.c +9 -2
- data/contrib/zstd/lib/common/error_private.h +82 -3
- data/contrib/zstd/lib/common/fse.h +9 -85
- data/contrib/zstd/lib/common/fse_decompress.c +29 -111
- data/contrib/zstd/lib/common/huf.h +84 -172
- data/contrib/zstd/lib/common/mem.h +58 -49
- data/contrib/zstd/lib/common/pool.c +37 -16
- data/contrib/zstd/lib/common/pool.h +9 -3
- data/contrib/zstd/lib/common/portability_macros.h +156 -0
- data/contrib/zstd/lib/common/threading.c +68 -14
- data/contrib/zstd/lib/common/threading.h +5 -10
- data/contrib/zstd/lib/common/xxhash.c +7 -809
- data/contrib/zstd/lib/common/xxhash.h +5568 -167
- data/contrib/zstd/lib/common/zstd_common.c +1 -36
- data/contrib/zstd/lib/common/zstd_deps.h +1 -1
- data/contrib/zstd/lib/common/zstd_internal.h +64 -150
- data/contrib/zstd/lib/common/zstd_trace.h +163 -0
- data/contrib/zstd/lib/compress/clevels.h +134 -0
- data/contrib/zstd/lib/compress/fse_compress.c +69 -150
- data/contrib/zstd/lib/compress/hist.c +1 -1
- data/contrib/zstd/lib/compress/hist.h +1 -1
- data/contrib/zstd/lib/compress/huf_compress.c +773 -251
- data/contrib/zstd/lib/compress/zstd_compress.c +2650 -826
- data/contrib/zstd/lib/compress/zstd_compress_internal.h +509 -180
- data/contrib/zstd/lib/compress/zstd_compress_literals.c +117 -40
- data/contrib/zstd/lib/compress/zstd_compress_literals.h +16 -6
- data/contrib/zstd/lib/compress/zstd_compress_sequences.c +28 -19
- data/contrib/zstd/lib/compress/zstd_compress_sequences.h +1 -1
- data/contrib/zstd/lib/compress/zstd_compress_superblock.c +33 -305
- data/contrib/zstd/lib/compress/zstd_compress_superblock.h +1 -1
- data/contrib/zstd/lib/compress/zstd_cwksp.h +266 -85
- data/contrib/zstd/lib/compress/zstd_double_fast.c +369 -132
- data/contrib/zstd/lib/compress/zstd_double_fast.h +3 -2
- data/contrib/zstd/lib/compress/zstd_fast.c +722 -258
- data/contrib/zstd/lib/compress/zstd_fast.h +3 -2
- data/contrib/zstd/lib/compress/zstd_lazy.c +1105 -360
- data/contrib/zstd/lib/compress/zstd_lazy.h +41 -1
- data/contrib/zstd/lib/compress/zstd_ldm.c +272 -208
- data/contrib/zstd/lib/compress/zstd_ldm.h +3 -2
- data/contrib/zstd/lib/compress/zstd_ldm_geartab.h +106 -0
- data/contrib/zstd/lib/compress/zstd_opt.c +324 -197
- data/contrib/zstd/lib/compress/zstd_opt.h +1 -1
- data/contrib/zstd/lib/compress/zstdmt_compress.c +109 -53
- data/contrib/zstd/lib/compress/zstdmt_compress.h +9 -6
- data/contrib/zstd/lib/decompress/huf_decompress.c +1071 -539
- data/contrib/zstd/lib/decompress/huf_decompress_amd64.S +576 -0
- data/contrib/zstd/lib/decompress/zstd_ddict.c +4 -4
- data/contrib/zstd/lib/decompress/zstd_ddict.h +1 -1
- data/contrib/zstd/lib/decompress/zstd_decompress.c +507 -82
- data/contrib/zstd/lib/decompress/zstd_decompress_block.c +962 -310
- data/contrib/zstd/lib/decompress/zstd_decompress_block.h +14 -3
- data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +54 -6
- data/contrib/zstd/lib/deprecated/zbuff.h +1 -1
- data/contrib/zstd/lib/deprecated/zbuff_common.c +1 -1
- data/contrib/zstd/lib/deprecated/zbuff_compress.c +24 -4
- data/contrib/zstd/lib/deprecated/zbuff_decompress.c +3 -1
- data/contrib/zstd/lib/dictBuilder/cover.c +44 -32
- data/contrib/zstd/lib/dictBuilder/cover.h +6 -5
- data/contrib/zstd/lib/dictBuilder/divsufsort.c +1 -1
- data/contrib/zstd/lib/dictBuilder/fastcover.c +24 -16
- data/contrib/zstd/lib/dictBuilder/zdict.c +88 -95
- data/contrib/zstd/lib/legacy/zstd_legacy.h +8 -1
- data/contrib/zstd/lib/legacy/zstd_v01.c +16 -53
- data/contrib/zstd/lib/legacy/zstd_v01.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v02.c +24 -69
- data/contrib/zstd/lib/legacy/zstd_v02.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v03.c +25 -72
- data/contrib/zstd/lib/legacy/zstd_v03.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v04.c +23 -69
- data/contrib/zstd/lib/legacy/zstd_v04.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v05.c +35 -85
- data/contrib/zstd/lib/legacy/zstd_v05.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v06.c +42 -87
- data/contrib/zstd/lib/legacy/zstd_v06.h +1 -1
- data/contrib/zstd/lib/legacy/zstd_v07.c +35 -82
- data/contrib/zstd/lib/legacy/zstd_v07.h +1 -1
- data/contrib/zstd/lib/libzstd.mk +214 -0
- data/contrib/zstd/lib/libzstd.pc.in +4 -3
- data/contrib/zstd/lib/module.modulemap +35 -0
- data/contrib/zstd/lib/{dictBuilder/zdict.h → zdict.h} +202 -33
- data/contrib/zstd/lib/zstd.h +922 -293
- data/contrib/zstd/lib/{common/zstd_errors.h → zstd_errors.h} +27 -8
- data/ext/extconf.rb +7 -6
- data/ext/extzstd.c +13 -10
- data/ext/libzstd_conf.h +0 -1
- data/ext/zstd_decompress_asm.S +1 -0
- metadata +16 -5
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c)
|
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
|
@@ -19,7 +19,7 @@
|
|
19
19
|
low-level memory access routines
|
20
20
|
Copyright (C) 2013-2015, Yann Collet.
|
21
21
|
|
22
|
-
BSD 2-Clause License (
|
22
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
23
23
|
|
24
24
|
Redistribution and use in source and binary forms, with or without
|
25
25
|
modification, are permitted provided that the following conditions are
|
@@ -106,27 +106,6 @@ extern "C" {
|
|
106
106
|
/*-**************************************************************
|
107
107
|
* Memory I/O
|
108
108
|
*****************************************************************/
|
109
|
-
/* MEM_FORCE_MEMORY_ACCESS :
|
110
|
-
* By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable.
|
111
|
-
* Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal.
|
112
|
-
* The below switch allow to select different access method for improved performance.
|
113
|
-
* Method 0 (default) : use `memcpy()`. Safe and portable.
|
114
|
-
* Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable).
|
115
|
-
* This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`.
|
116
|
-
* Method 2 : direct access. This method is portable but violate C standard.
|
117
|
-
* It can generate buggy code on targets depending on alignment.
|
118
|
-
* In some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6)
|
119
|
-
* See http://fastcompression.blogspot.fr/2015/08/accessing-unaligned-memory.html for details.
|
120
|
-
* Prefer these methods in priority order (0 > 1 > 2)
|
121
|
-
*/
|
122
|
-
#ifndef MEM_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
|
123
|
-
# if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) )
|
124
|
-
# define MEM_FORCE_MEMORY_ACCESS 2
|
125
|
-
# elif (defined(__INTEL_COMPILER) && !defined(WIN32)) || \
|
126
|
-
(defined(__GNUC__) && ( defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) ))
|
127
|
-
# define MEM_FORCE_MEMORY_ACCESS 1
|
128
|
-
# endif
|
129
|
-
#endif
|
130
109
|
|
131
110
|
MEM_STATIC unsigned MEM_32bits(void) { return sizeof(void*)==4; }
|
132
111
|
MEM_STATIC unsigned MEM_64bits(void) { return sizeof(void*)==8; }
|
@@ -137,37 +116,6 @@ MEM_STATIC unsigned MEM_isLittleEndian(void)
|
|
137
116
|
return one.c[0];
|
138
117
|
}
|
139
118
|
|
140
|
-
#if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2)
|
141
|
-
|
142
|
-
/* violates C standard, by lying on structure alignment.
|
143
|
-
Only use if no other choice to achieve best performance on target platform */
|
144
|
-
MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; }
|
145
|
-
MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; }
|
146
|
-
MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; }
|
147
|
-
|
148
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
|
149
|
-
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; }
|
150
|
-
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { *(U64*)memPtr = value; }
|
151
|
-
|
152
|
-
#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1)
|
153
|
-
|
154
|
-
/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
|
155
|
-
/* currently only defined for gcc and icc */
|
156
|
-
typedef union { U16 u16; U32 u32; U64 u64; size_t st; } __attribute__((packed)) unalign;
|
157
|
-
|
158
|
-
MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign*)ptr)->u16; }
|
159
|
-
MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
|
160
|
-
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign*)ptr)->u64; }
|
161
|
-
|
162
|
-
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; }
|
163
|
-
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((unalign*)memPtr)->u32 = value; }
|
164
|
-
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { ((unalign*)memPtr)->u64 = value; }
|
165
|
-
|
166
|
-
#else
|
167
|
-
|
168
|
-
/* default method, safe and standard.
|
169
|
-
can sometimes prove slower */
|
170
|
-
|
171
119
|
MEM_STATIC U16 MEM_read16(const void* memPtr)
|
172
120
|
{
|
173
121
|
U16 val; memcpy(&val, memPtr, sizeof(val)); return val;
|
@@ -198,9 +146,6 @@ MEM_STATIC void MEM_write64(void* memPtr, U64 value)
|
|
198
146
|
memcpy(memPtr, &value, sizeof(value));
|
199
147
|
}
|
200
148
|
|
201
|
-
#endif /* MEM_FORCE_MEMORY_ACCESS */
|
202
|
-
|
203
|
-
|
204
149
|
MEM_STATIC U16 MEM_readLE16(const void* memPtr)
|
205
150
|
{
|
206
151
|
if (MEM_isLittleEndian())
|
@@ -265,7 +210,7 @@ MEM_STATIC size_t MEM_readLEST(const void* memPtr)
|
|
265
210
|
Header File for static linking only
|
266
211
|
Copyright (C) 2014-2016, Yann Collet.
|
267
212
|
|
268
|
-
BSD 2-Clause License (
|
213
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
269
214
|
|
270
215
|
Redistribution and use in source and binary forms, with or without
|
271
216
|
modification, are permitted provided that the following conditions are
|
@@ -289,7 +234,7 @@ MEM_STATIC size_t MEM_readLEST(const void* memPtr)
|
|
289
234
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
290
235
|
|
291
236
|
You can contact the author at :
|
292
|
-
- zstd homepage :
|
237
|
+
- zstd homepage : https://facebook.github.io/zstd
|
293
238
|
*/
|
294
239
|
#ifndef ZSTD_STATIC_H
|
295
240
|
#define ZSTD_STATIC_H
|
@@ -401,7 +346,7 @@ size_t ZSTDv05_decompressBlock(ZSTDv05_DCtx* dctx, void* dst, size_t dstCapacity
|
|
401
346
|
Header File for include
|
402
347
|
Copyright (C) 2014-2016, Yann Collet.
|
403
348
|
|
404
|
-
BSD 2-Clause License (
|
349
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
405
350
|
|
406
351
|
Redistribution and use in source and binary forms, with or without
|
407
352
|
modification, are permitted provided that the following conditions are
|
@@ -488,7 +433,7 @@ static const size_t ZSTDv05_frameHeaderSize_min = 5;
|
|
488
433
|
#define FSEv05_ENCODING_DYNAMIC 3
|
489
434
|
|
490
435
|
|
491
|
-
#define
|
436
|
+
#define ZSTD_HUFFDTABLE_CAPACITY_LOG 12
|
492
437
|
|
493
438
|
#define MIN_SEQUENCES_SIZE 1 /* nbSeq==0 */
|
494
439
|
#define MIN_CBLOCK_SIZE (1 /*litCSize*/ + 1 /* RLE or RAW */ + MIN_SEQUENCES_SIZE /* nbSeq==0 */) /* for a non-null block */
|
@@ -556,7 +501,7 @@ typedef struct {
|
|
556
501
|
header file
|
557
502
|
Copyright (C) 2013-2015, Yann Collet.
|
558
503
|
|
559
|
-
BSD 2-Clause License (
|
504
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
560
505
|
|
561
506
|
Redistribution and use in source and binary forms, with or without
|
562
507
|
modification, are permitted provided that the following conditions are
|
@@ -675,7 +620,7 @@ size_t FSEv05_decompress_usingDTable(void* dst, size_t dstCapacity, const void*
|
|
675
620
|
header file (to include)
|
676
621
|
Copyright (C) 2013-2016, Yann Collet.
|
677
622
|
|
678
|
-
BSD 2-Clause License (
|
623
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
679
624
|
|
680
625
|
Redistribution and use in source and binary forms, with or without
|
681
626
|
modification, are permitted provided that the following conditions are
|
@@ -756,9 +701,8 @@ MEM_STATIC size_t BITv05_readBitsFast(BITv05_DStream_t* bitD, unsigned nbBits);
|
|
756
701
|
MEM_STATIC unsigned BITv05_highbit32 (U32 val)
|
757
702
|
{
|
758
703
|
# if defined(_MSC_VER) /* Visual */
|
759
|
-
unsigned long r
|
760
|
-
_BitScanReverse
|
761
|
-
return (unsigned) r;
|
704
|
+
unsigned long r;
|
705
|
+
return _BitScanReverse(&r, val) ? (unsigned)r : 0;
|
762
706
|
# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */
|
763
707
|
return __builtin_clz (val) ^ 31;
|
764
708
|
# else /* Software version */
|
@@ -830,7 +774,7 @@ MEM_STATIC size_t BITv05_lookBits(BITv05_DStream_t* bitD, U32 nbBits)
|
|
830
774
|
}
|
831
775
|
|
832
776
|
/*! BITv05_lookBitsFast :
|
833
|
-
* unsafe version; only works
|
777
|
+
* unsafe version; only works if nbBits >= 1 */
|
834
778
|
MEM_STATIC size_t BITv05_lookBitsFast(BITv05_DStream_t* bitD, U32 nbBits)
|
835
779
|
{
|
836
780
|
const U32 bitMask = sizeof(bitD->bitContainer)*8 - 1;
|
@@ -850,7 +794,7 @@ MEM_STATIC size_t BITv05_readBits(BITv05_DStream_t* bitD, unsigned nbBits)
|
|
850
794
|
}
|
851
795
|
|
852
796
|
/*!BITv05_readBitsFast :
|
853
|
-
* unsafe version; only works
|
797
|
+
* unsafe version; only works if nbBits >= 1 */
|
854
798
|
MEM_STATIC size_t BITv05_readBitsFast(BITv05_DStream_t* bitD, unsigned nbBits)
|
855
799
|
{
|
856
800
|
size_t value = BITv05_lookBitsFast(bitD, nbBits);
|
@@ -905,7 +849,7 @@ MEM_STATIC unsigned BITv05_endOfDStream(const BITv05_DStream_t* DStream)
|
|
905
849
|
header file for static linking (only)
|
906
850
|
Copyright (C) 2013-2015, Yann Collet
|
907
851
|
|
908
|
-
BSD 2-Clause License (
|
852
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
909
853
|
|
910
854
|
Redistribution and use in source and binary forms, with or without
|
911
855
|
modification, are permitted provided that the following conditions are
|
@@ -1055,7 +999,7 @@ MEM_STATIC unsigned FSEv05_endOfDState(const FSEv05_DState_t* DStatePtr)
|
|
1055
999
|
FSEv05 : Finite State Entropy coder
|
1056
1000
|
Copyright (C) 2013-2015, Yann Collet.
|
1057
1001
|
|
1058
|
-
BSD 2-Clause License (
|
1002
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
1059
1003
|
|
1060
1004
|
Redistribution and use in source and binary forms, with or without
|
1061
1005
|
modification, are permitted provided that the following conditions are
|
@@ -1541,7 +1485,7 @@ size_t FSEv05_decompress(void* dst, size_t maxDstSize, const void* cSrc, size_t
|
|
1541
1485
|
header file
|
1542
1486
|
Copyright (C) 2013-2016, Yann Collet.
|
1543
1487
|
|
1544
|
-
BSD 2-Clause License (
|
1488
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
1545
1489
|
|
1546
1490
|
Redistribution and use in source and binary forms, with or without
|
1547
1491
|
modification, are permitted provided that the following conditions are
|
@@ -1614,7 +1558,7 @@ const char* HUFv05_getErrorName(size_t code); /* provides error code string (u
|
|
1614
1558
|
header file, for static linking only
|
1615
1559
|
Copyright (C) 2013-2016, Yann Collet
|
1616
1560
|
|
1617
|
-
BSD 2-Clause License (
|
1561
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
1618
1562
|
|
1619
1563
|
Redistribution and use in source and binary forms, with or without
|
1620
1564
|
modification, are permitted provided that the following conditions are
|
@@ -1706,7 +1650,7 @@ size_t HUFv05_decompress1X4_usingDTable(void* dst, size_t maxDstSize, const void
|
|
1706
1650
|
Huff0 : Huffman coder, part of New Generation Entropy library
|
1707
1651
|
Copyright (C) 2013-2015, Yann Collet.
|
1708
1652
|
|
1709
|
-
BSD 2-Clause License (
|
1653
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
1710
1654
|
|
1711
1655
|
Redistribution and use in source and binary forms, with or without
|
1712
1656
|
modification, are permitted provided that the following conditions are
|
@@ -2551,7 +2495,7 @@ size_t HUFv05_decompress (void* dst, size_t dstSize, const void* cSrc, size_t cS
|
|
2551
2495
|
zstd - standard compression library
|
2552
2496
|
Copyright (C) 2014-2016, Yann Collet.
|
2553
2497
|
|
2554
|
-
BSD 2-Clause License (
|
2498
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
2555
2499
|
|
2556
2500
|
Redistribution and use in source and binary forms, with or without
|
2557
2501
|
modification, are permitted provided that the following conditions are
|
@@ -2649,7 +2593,7 @@ struct ZSTDv05_DCtx_s
|
|
2649
2593
|
FSEv05_DTable LLTable[FSEv05_DTABLE_SIZE_U32(LLFSEv05Log)];
|
2650
2594
|
FSEv05_DTable OffTable[FSEv05_DTABLE_SIZE_U32(OffFSEv05Log)];
|
2651
2595
|
FSEv05_DTable MLTable[FSEv05_DTABLE_SIZE_U32(MLFSEv05Log)];
|
2652
|
-
unsigned hufTableX4[HUFv05_DTABLE_SIZE(
|
2596
|
+
unsigned hufTableX4[HUFv05_DTABLE_SIZE(ZSTD_HUFFDTABLE_CAPACITY_LOG)];
|
2653
2597
|
const void* previousDstEnd;
|
2654
2598
|
const void* base;
|
2655
2599
|
const void* vBase;
|
@@ -2677,7 +2621,7 @@ size_t ZSTDv05_decompressBegin(ZSTDv05_DCtx* dctx)
|
|
2677
2621
|
dctx->base = NULL;
|
2678
2622
|
dctx->vBase = NULL;
|
2679
2623
|
dctx->dictEnd = NULL;
|
2680
|
-
dctx->hufTableX4[0] =
|
2624
|
+
dctx->hufTableX4[0] = ZSTD_HUFFDTABLE_CAPACITY_LOG;
|
2681
2625
|
dctx->flagStaticTables = 0;
|
2682
2626
|
return 0;
|
2683
2627
|
}
|
@@ -2833,7 +2777,7 @@ static size_t ZSTDv05_decodeFrameHeader_Part2(ZSTDv05_DCtx* zc, const void* src,
|
|
2833
2777
|
|
2834
2778
|
static size_t ZSTDv05_getcBlockSize(const void* src, size_t srcSize, blockProperties_t* bpPtr)
|
2835
2779
|
{
|
2836
|
-
const BYTE* const in = (const BYTE*
|
2780
|
+
const BYTE* const in = (const BYTE*)src;
|
2837
2781
|
BYTE headerFlags;
|
2838
2782
|
U32 cSize;
|
2839
2783
|
|
@@ -3002,7 +2946,7 @@ static size_t ZSTDv05_decodeSeqHeaders(int* nbSeq, const BYTE** dumpsPtr, size_t
|
|
3002
2946
|
FSEv05_DTable* DTableLL, FSEv05_DTable* DTableML, FSEv05_DTable* DTableOffb,
|
3003
2947
|
const void* src, size_t srcSize, U32 flagStaticTable)
|
3004
2948
|
{
|
3005
|
-
const BYTE* const istart = (const BYTE*
|
2949
|
+
const BYTE* const istart = (const BYTE*)src;
|
3006
2950
|
const BYTE* ip = istart;
|
3007
2951
|
const BYTE* const iend = istart + srcSize;
|
3008
2952
|
U32 LLtype, Offtype, MLtype;
|
@@ -3238,13 +3182,19 @@ static size_t ZSTDv05_execSequence(BYTE* op,
|
|
3238
3182
|
const BYTE* const litEnd = *litPtr + sequence.litLength;
|
3239
3183
|
const BYTE* match = oLitEnd - sequence.offset;
|
3240
3184
|
|
3241
|
-
/*
|
3242
|
-
|
3185
|
+
/* checks */
|
3186
|
+
size_t const seqLength = sequence.litLength + sequence.matchLength;
|
3187
|
+
|
3188
|
+
if (seqLength > (size_t)(oend - op)) return ERROR(dstSize_tooSmall);
|
3189
|
+
if (sequence.litLength > (size_t)(litLimit - *litPtr)) return ERROR(corruption_detected);
|
3190
|
+
/* Now we know there are no overflow in literal nor match lengths, can use pointer checks */
|
3191
|
+
if (oLitEnd > oend_8) return ERROR(dstSize_tooSmall);
|
3192
|
+
|
3243
3193
|
if (oMatchEnd > oend) return ERROR(dstSize_tooSmall); /* overwrite beyond dst buffer */
|
3244
|
-
if (litEnd > litLimit) return ERROR(corruption_detected); /*
|
3194
|
+
if (litEnd > litLimit) return ERROR(corruption_detected); /* overRead beyond lit buffer */
|
3245
3195
|
|
3246
3196
|
/* copy Literals */
|
3247
|
-
ZSTDv05_wildcopy(op, *litPtr, sequence.litLength); /* note : oLitEnd <= oend-8 : no risk of overwrite beyond oend */
|
3197
|
+
ZSTDv05_wildcopy(op, *litPtr, (ptrdiff_t)sequence.litLength); /* note : oLitEnd <= oend-8 : no risk of overwrite beyond oend */
|
3248
3198
|
op = oLitEnd;
|
3249
3199
|
*litPtr = litEnd; /* update for next sequence */
|
3250
3200
|
|
@@ -3310,7 +3260,7 @@ static size_t ZSTDv05_decompressSequences(
|
|
3310
3260
|
{
|
3311
3261
|
const BYTE* ip = (const BYTE*)seqStart;
|
3312
3262
|
const BYTE* const iend = ip + seqSize;
|
3313
|
-
BYTE* const ostart = (BYTE*
|
3263
|
+
BYTE* const ostart = (BYTE*)dst;
|
3314
3264
|
BYTE* op = ostart;
|
3315
3265
|
BYTE* const oend = ostart + maxDstSize;
|
3316
3266
|
size_t errorCode, dumpsLength=0;
|
@@ -3423,7 +3373,7 @@ static size_t ZSTDv05_decompress_continueDCtx(ZSTDv05_DCtx* dctx,
|
|
3423
3373
|
{
|
3424
3374
|
const BYTE* ip = (const BYTE*)src;
|
3425
3375
|
const BYTE* iend = ip + srcSize;
|
3426
|
-
BYTE* const ostart = (BYTE*
|
3376
|
+
BYTE* const ostart = (BYTE*)dst;
|
3427
3377
|
BYTE* op = ostart;
|
3428
3378
|
BYTE* const oend = ostart + maxDstSize;
|
3429
3379
|
size_t remainingSize = srcSize;
|
@@ -3750,7 +3700,7 @@ size_t ZSTDv05_decompressBegin_usingDict(ZSTDv05_DCtx* dctx, const void* dict, s
|
|
3750
3700
|
Buffered version of Zstd compression library
|
3751
3701
|
Copyright (C) 2015-2016, Yann Collet.
|
3752
3702
|
|
3753
|
-
BSD 2-Clause License (
|
3703
|
+
BSD 2-Clause License (https://opensource.org/licenses/bsd-license.php)
|
3754
3704
|
|
3755
3705
|
Redistribution and use in source and binary forms, with or without
|
3756
3706
|
modification, are permitted provided that the following conditions are
|