extlz4 0.3.3 → 0.3.4
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/README.md +1 -1
- data/Rakefile +22 -0
- data/contrib/lz4/LICENSE +2 -1
- data/contrib/lz4/Makefile.inc +39 -15
- data/contrib/lz4/NEWS +21 -0
- data/contrib/lz4/README.md +1 -1
- data/contrib/lz4/build/VS2010/liblz4-dll/liblz4-dll.rc +1 -1
- data/contrib/lz4/build/VS2010/lz4/lz4.rc +1 -1
- data/contrib/lz4/build/VS2017/liblz4-dll/liblz4-dll.rc +1 -1
- data/contrib/lz4/build/VS2017/lz4/lz4.rc +1 -1
- data/contrib/lz4/build/VS2017/lz4/lz4.vcxproj +12 -1
- data/contrib/lz4/build/VS2022/datagen/datagen.vcxproj +173 -0
- data/contrib/lz4/build/VS2022/frametest/frametest.vcxproj +180 -0
- data/contrib/lz4/build/VS2022/fullbench/fullbench.vcxproj +180 -0
- data/contrib/lz4/build/VS2022/fullbench-dll/fullbench-dll.vcxproj +184 -0
- data/contrib/lz4/build/VS2022/fuzzer/fuzzer.vcxproj +177 -0
- data/contrib/lz4/build/VS2022/liblz4/liblz4.vcxproj +179 -0
- data/contrib/lz4/build/VS2022/liblz4-dll/liblz4-dll.rc +51 -0
- data/contrib/lz4/build/VS2022/liblz4-dll/liblz4-dll.vcxproj +183 -0
- data/contrib/lz4/build/VS2022/lz4.sln +103 -0
- data/contrib/lz4/build/cmake/CMakeLists.txt +49 -11
- data/contrib/lz4/build/cmake/lz4Config.cmake.in +2 -0
- data/contrib/lz4/lib/LICENSE +1 -1
- data/contrib/lz4/lib/README.md +45 -13
- data/contrib/lz4/lib/liblz4-dll.rc.in +1 -1
- data/contrib/lz4/lib/liblz4.pc.in +3 -3
- data/contrib/lz4/lib/lz4.c +422 -195
- data/contrib/lz4/lib/lz4.h +114 -46
- data/contrib/lz4/lib/lz4file.c +311 -0
- data/contrib/lz4/lib/lz4file.h +93 -0
- data/contrib/lz4/lib/lz4frame.c +421 -242
- data/contrib/lz4/lib/lz4frame.h +122 -53
- data/contrib/lz4/lib/lz4frame_static.h +1 -1
- data/contrib/lz4/lib/lz4hc.c +127 -111
- data/contrib/lz4/lib/lz4hc.h +14 -14
- data/contrib/lz4/ossfuzz/Makefile +1 -0
- data/contrib/lz4/ossfuzz/decompress_fuzzer.c +18 -2
- data/contrib/lz4/ossfuzz/fuzz_helpers.h +3 -2
- data/contrib/lz4/ossfuzz/round_trip_frame_uncompressed_fuzzer.c +134 -0
- data/contrib/lz4/ossfuzz/round_trip_fuzzer.c +66 -6
- data/ext/blockapi.c +8 -8
- data/ext/extlz4.h +12 -0
- data/ext/frameapi.c +3 -3
- data/ext/hashargs.c +7 -1
- metadata +16 -5
- data/contrib/lz4/tmp +0 -0
- data/contrib/lz4/tmpsparse +0 -0
@@ -39,7 +39,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
39
39
|
/* No dictionary. */
|
40
40
|
LZ4_decompress_safe_usingDict((char const*)data, dst, size,
|
41
41
|
dstCapacity, NULL, 0);
|
42
|
-
/* Small external
|
42
|
+
/* Small external dictionary. */
|
43
43
|
LZ4_decompress_safe_usingDict((char const*)data, dst, size,
|
44
44
|
dstCapacity, smallDict, smallDictSize);
|
45
45
|
/* Large external dictionary. */
|
@@ -49,11 +49,27 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
49
49
|
LZ4_decompress_safe_usingDict((char const*)dataAfterDict, dst, size,
|
50
50
|
dstCapacity, smallDict, smallDictSize);
|
51
51
|
/* Large prefix. */
|
52
|
-
LZ4_decompress_safe_usingDict((char const*)
|
52
|
+
LZ4_decompress_safe_usingDict((char const*)dataAfterDict, dst, size,
|
53
53
|
dstCapacity, largeDict, largeDictSize);
|
54
54
|
/* Partial decompression. */
|
55
55
|
LZ4_decompress_safe_partial((char const*)data, dst, size,
|
56
56
|
dstCapacity, dstCapacity);
|
57
|
+
/* Partial decompression using each possible dictionary configuration. */
|
58
|
+
/* Partial decompression with no dictionary. */
|
59
|
+
LZ4_decompress_safe_partial_usingDict((char const*)data, dst, size,
|
60
|
+
dstCapacity, dstCapacity, NULL, 0);
|
61
|
+
/* Partial decompression with small external dictionary. */
|
62
|
+
LZ4_decompress_safe_partial_usingDict((char const*)data, dst, size,
|
63
|
+
dstCapacity, dstCapacity, smallDict, smallDictSize);
|
64
|
+
/* Partial decompression with large external dictionary. */
|
65
|
+
LZ4_decompress_safe_partial_usingDict((char const*)data, dst, size,
|
66
|
+
dstCapacity, dstCapacity, largeDict, largeDictSize);
|
67
|
+
/* Partial decompression with small prefix. */
|
68
|
+
LZ4_decompress_safe_partial_usingDict((char const*)dataAfterDict, dst, size,
|
69
|
+
dstCapacity, dstCapacity, smallDict, smallDictSize);
|
70
|
+
/* Partial decompression wtih large prefix. */
|
71
|
+
LZ4_decompress_safe_partial_usingDict((char const*)dataAfterDict, dst, size,
|
72
|
+
dstCapacity, dstCapacity, largeDict, largeDictSize);
|
57
73
|
free(dst);
|
58
74
|
free(dict);
|
59
75
|
FUZZ_dataProducer_free(producer);
|
@@ -4,7 +4,8 @@
|
|
4
4
|
*
|
5
5
|
* This source code is licensed under both the BSD-style license (found in the
|
6
6
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
|
-
* in the COPYING file in the root directory of this source tree)
|
7
|
+
* in the COPYING file in the root directory of this source tree),
|
8
|
+
* meaning you may select, at your option, one of the above-listed licenses.
|
8
9
|
*/
|
9
10
|
|
10
11
|
/**
|
@@ -81,7 +82,7 @@ FUZZ_STATIC uint32_t FUZZ_rand(uint32_t *state) {
|
|
81
82
|
return rand32 >> 5;
|
82
83
|
}
|
83
84
|
|
84
|
-
/* Returns a random
|
85
|
+
/* Returns a random number in the range [min, max]. */
|
85
86
|
FUZZ_STATIC uint32_t FUZZ_rand32(uint32_t *state, uint32_t min, uint32_t max) {
|
86
87
|
uint32_t random = FUZZ_rand(state);
|
87
88
|
return min + (random % (max - min + 1));
|
@@ -0,0 +1,134 @@
|
|
1
|
+
/**
|
2
|
+
* This fuzz target performs a lz4 round-trip test (compress & decompress),
|
3
|
+
* compares the result with the original, and calls abort() on corruption.
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include <stddef.h>
|
7
|
+
#include <stdint.h>
|
8
|
+
#include <stdlib.h>
|
9
|
+
#include <string.h>
|
10
|
+
|
11
|
+
#include "fuzz_data_producer.h"
|
12
|
+
#include "fuzz_helpers.h"
|
13
|
+
#include "lz4.h"
|
14
|
+
#include "lz4_helpers.h"
|
15
|
+
#include "lz4frame.h"
|
16
|
+
#include "lz4frame_static.h"
|
17
|
+
|
18
|
+
static void decompress(LZ4F_dctx *dctx, void *src, void *dst,
|
19
|
+
size_t dstCapacity, size_t readSize) {
|
20
|
+
size_t ret = 1;
|
21
|
+
const void *srcPtr = (const char *) src;
|
22
|
+
void *dstPtr = (char *) dst;
|
23
|
+
const void *const srcEnd = (const char *) srcPtr + readSize;
|
24
|
+
|
25
|
+
while (ret != 0) {
|
26
|
+
while (srcPtr < srcEnd && ret != 0) {
|
27
|
+
/* Any data within dst has been flushed at this stage */
|
28
|
+
size_t dstSize = dstCapacity;
|
29
|
+
size_t srcSize = (const char *) srcEnd - (const char *) srcPtr;
|
30
|
+
ret = LZ4F_decompress(dctx, dstPtr, &dstSize, srcPtr, &srcSize,
|
31
|
+
/* LZ4F_decompressOptions_t */ NULL);
|
32
|
+
FUZZ_ASSERT(!LZ4F_isError(ret));
|
33
|
+
|
34
|
+
/* Update input */
|
35
|
+
srcPtr = (const char *) srcPtr + srcSize;
|
36
|
+
dstPtr = (char *) dstPtr + dstSize;
|
37
|
+
}
|
38
|
+
|
39
|
+
FUZZ_ASSERT(srcPtr <= srcEnd);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
static void compress_round_trip(const uint8_t *data, size_t size,
|
44
|
+
FUZZ_dataProducer_t *producer, LZ4F_preferences_t const prefs) {
|
45
|
+
|
46
|
+
// Choose random uncompressed offset start and end by producing seeds from random data, calculate the remaining
|
47
|
+
// data size that will be used for compression later and use the seeds to actually calculate the offsets
|
48
|
+
size_t const uncompressedOffsetSeed = FUZZ_dataProducer_retrieve32(producer);
|
49
|
+
size_t const uncompressedEndOffsetSeed = FUZZ_dataProducer_retrieve32(producer);
|
50
|
+
size = FUZZ_dataProducer_remainingBytes(producer);
|
51
|
+
|
52
|
+
size_t const uncompressedOffset = FUZZ_getRange_from_uint32(uncompressedOffsetSeed, 0, size);
|
53
|
+
size_t const uncompressedEndOffset = FUZZ_getRange_from_uint32(uncompressedEndOffsetSeed, uncompressedOffset, size);
|
54
|
+
size_t const uncompressedSize = uncompressedEndOffset - uncompressedOffset;
|
55
|
+
FUZZ_ASSERT(uncompressedOffset <= uncompressedEndOffset);
|
56
|
+
FUZZ_ASSERT(uncompressedEndOffset <= size);
|
57
|
+
|
58
|
+
const uint8_t *const uncompressedData = data + uncompressedOffset;
|
59
|
+
|
60
|
+
size_t const dstCapacity =
|
61
|
+
LZ4F_compressFrameBound(LZ4_compressBound(size), &prefs) +
|
62
|
+
uncompressedSize;
|
63
|
+
char *const dst = (char *) malloc(dstCapacity);
|
64
|
+
size_t rtCapacity = dstCapacity;
|
65
|
+
char *const rt = (char *) malloc(rtCapacity);
|
66
|
+
|
67
|
+
FUZZ_ASSERT(dst);
|
68
|
+
FUZZ_ASSERT(rt);
|
69
|
+
|
70
|
+
/* Compression must succeed and round trip correctly. */
|
71
|
+
LZ4F_compressionContext_t ctx;
|
72
|
+
size_t const ctxCreation = LZ4F_createCompressionContext(&ctx, LZ4F_VERSION);
|
73
|
+
FUZZ_ASSERT(!LZ4F_isError(ctxCreation));
|
74
|
+
|
75
|
+
size_t const headerSize = LZ4F_compressBegin(ctx, dst, dstCapacity, &prefs);
|
76
|
+
FUZZ_ASSERT(!LZ4F_isError(headerSize));
|
77
|
+
size_t compressedSize = headerSize;
|
78
|
+
|
79
|
+
/* Compress data before uncompressed offset */
|
80
|
+
size_t lz4Return = LZ4F_compressUpdate(ctx, dst + compressedSize, dstCapacity,
|
81
|
+
data, uncompressedOffset, NULL);
|
82
|
+
FUZZ_ASSERT(!LZ4F_isError(lz4Return));
|
83
|
+
compressedSize += lz4Return;
|
84
|
+
|
85
|
+
/* Add uncompressed data */
|
86
|
+
lz4Return = LZ4F_uncompressedUpdate(ctx, dst + compressedSize, dstCapacity,
|
87
|
+
uncompressedData, uncompressedSize, NULL);
|
88
|
+
FUZZ_ASSERT(!LZ4F_isError(lz4Return));
|
89
|
+
compressedSize += lz4Return;
|
90
|
+
|
91
|
+
/* Compress data after uncompressed offset */
|
92
|
+
lz4Return = LZ4F_compressUpdate(ctx, dst + compressedSize, dstCapacity,
|
93
|
+
data + uncompressedEndOffset,
|
94
|
+
size - uncompressedEndOffset, NULL);
|
95
|
+
FUZZ_ASSERT(!LZ4F_isError(lz4Return));
|
96
|
+
compressedSize += lz4Return;
|
97
|
+
|
98
|
+
/* Finish compression */
|
99
|
+
lz4Return = LZ4F_compressEnd(ctx, dst + compressedSize, dstCapacity, NULL);
|
100
|
+
FUZZ_ASSERT(!LZ4F_isError(lz4Return));
|
101
|
+
compressedSize += lz4Return;
|
102
|
+
|
103
|
+
LZ4F_decompressOptions_t opts;
|
104
|
+
memset(&opts, 0, sizeof(opts));
|
105
|
+
opts.stableDst = 1;
|
106
|
+
LZ4F_dctx *dctx;
|
107
|
+
LZ4F_createDecompressionContext(&dctx, LZ4F_VERSION);
|
108
|
+
FUZZ_ASSERT(dctx);
|
109
|
+
|
110
|
+
decompress(dctx, dst, rt, rtCapacity, compressedSize);
|
111
|
+
|
112
|
+
LZ4F_freeDecompressionContext(dctx);
|
113
|
+
|
114
|
+
FUZZ_ASSERT_MSG(!memcmp(data, rt, size), "Corruption!");
|
115
|
+
|
116
|
+
free(dst);
|
117
|
+
free(rt);
|
118
|
+
|
119
|
+
FUZZ_dataProducer_free(producer);
|
120
|
+
LZ4F_freeCompressionContext(ctx);
|
121
|
+
}
|
122
|
+
|
123
|
+
static void compress_independent_block_mode(const uint8_t *data, size_t size) {
|
124
|
+
FUZZ_dataProducer_t *producer = FUZZ_dataProducer_create(data, size);
|
125
|
+
LZ4F_preferences_t prefs = FUZZ_dataProducer_preferences(producer);
|
126
|
+
prefs.frameInfo.blockMode = LZ4F_blockIndependent;
|
127
|
+
compress_round_trip(data, size, producer, prefs);
|
128
|
+
}
|
129
|
+
|
130
|
+
|
131
|
+
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
132
|
+
compress_independent_block_mode(data, size);
|
133
|
+
return 0;
|
134
|
+
}
|
@@ -20,11 +20,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
20
20
|
|
21
21
|
size_t const partialCapacity = FUZZ_getRange_from_uint32(partialCapacitySeed, 0, size);
|
22
22
|
size_t const dstCapacity = LZ4_compressBound(size);
|
23
|
-
|
24
|
-
|
23
|
+
size_t const largeSize = 64 * 1024 - 1;
|
24
|
+
size_t const smallSize = 1024;
|
25
|
+
char* const dstPlusLargePrefix = (char*)malloc(dstCapacity + largeSize);
|
26
|
+
FUZZ_ASSERT(dstPlusLargePrefix);
|
27
|
+
char* const dstPlusSmallPrefix = dstPlusLargePrefix + largeSize - smallSize;
|
28
|
+
char* const largeDict = (char*)malloc(largeSize);
|
29
|
+
FUZZ_ASSERT(largeDict);
|
30
|
+
char* const smallDict = largeDict + largeSize - smallSize;
|
31
|
+
char* const dst = dstPlusLargePrefix + largeSize;
|
25
32
|
char* const rt = (char*)malloc(size);
|
26
|
-
|
27
|
-
FUZZ_ASSERT(dst);
|
28
33
|
FUZZ_ASSERT(rt);
|
29
34
|
|
30
35
|
/* Compression must succeed and round trip correctly. */
|
@@ -47,9 +52,64 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
47
52
|
FUZZ_ASSERT_MSG(!memcmp(data, partial, partialSize), "Corruption!");
|
48
53
|
free(partial);
|
49
54
|
}
|
55
|
+
/* Partial decompression using dict with no dict. */
|
56
|
+
{
|
57
|
+
char* const partial = (char*)malloc(partialCapacity);
|
58
|
+
FUZZ_ASSERT(partial);
|
59
|
+
int const partialSize = LZ4_decompress_safe_partial_usingDict(
|
60
|
+
dst, partial, dstSize, partialCapacity, partialCapacity, NULL, 0);
|
61
|
+
FUZZ_ASSERT(partialSize >= 0);
|
62
|
+
FUZZ_ASSERT_MSG(partialSize == partialCapacity, "Incorrect size");
|
63
|
+
FUZZ_ASSERT_MSG(!memcmp(data, partial, partialSize), "Corruption!");
|
64
|
+
free(partial);
|
65
|
+
}
|
66
|
+
/* Partial decompression using dict with small prefix as dict */
|
67
|
+
{
|
68
|
+
char* const partial = (char*)malloc(partialCapacity);
|
69
|
+
FUZZ_ASSERT(partial);
|
70
|
+
int const partialSize = LZ4_decompress_safe_partial_usingDict(
|
71
|
+
dst, partial, dstSize, partialCapacity, partialCapacity, dstPlusSmallPrefix, smallSize);
|
72
|
+
FUZZ_ASSERT(partialSize >= 0);
|
73
|
+
FUZZ_ASSERT_MSG(partialSize == partialCapacity, "Incorrect size");
|
74
|
+
FUZZ_ASSERT_MSG(!memcmp(data, partial, partialSize), "Corruption!");
|
75
|
+
free(partial);
|
76
|
+
}
|
77
|
+
/* Partial decompression using dict with large prefix as dict */
|
78
|
+
{
|
79
|
+
char* const partial = (char*)malloc(partialCapacity);
|
80
|
+
FUZZ_ASSERT(partial);
|
81
|
+
int const partialSize = LZ4_decompress_safe_partial_usingDict(
|
82
|
+
dst, partial, dstSize, partialCapacity, partialCapacity, dstPlusLargePrefix, largeSize);
|
83
|
+
FUZZ_ASSERT(partialSize >= 0);
|
84
|
+
FUZZ_ASSERT_MSG(partialSize == partialCapacity, "Incorrect size");
|
85
|
+
FUZZ_ASSERT_MSG(!memcmp(data, partial, partialSize), "Corruption!");
|
86
|
+
free(partial);
|
87
|
+
}
|
88
|
+
/* Partial decompression using dict with small external dict */
|
89
|
+
{
|
90
|
+
char* const partial = (char*)malloc(partialCapacity);
|
91
|
+
FUZZ_ASSERT(partial);
|
92
|
+
int const partialSize = LZ4_decompress_safe_partial_usingDict(
|
93
|
+
dst, partial, dstSize, partialCapacity, partialCapacity, smallDict, smallSize);
|
94
|
+
FUZZ_ASSERT(partialSize >= 0);
|
95
|
+
FUZZ_ASSERT_MSG(partialSize == partialCapacity, "Incorrect size");
|
96
|
+
FUZZ_ASSERT_MSG(!memcmp(data, partial, partialSize), "Corruption!");
|
97
|
+
free(partial);
|
98
|
+
}
|
99
|
+
/* Partial decompression using dict with large external dict */
|
100
|
+
{
|
101
|
+
char* const partial = (char*)malloc(partialCapacity);
|
102
|
+
FUZZ_ASSERT(partial);
|
103
|
+
int const partialSize = LZ4_decompress_safe_partial_usingDict(
|
104
|
+
dst, partial, dstSize, partialCapacity, partialCapacity, largeDict, largeSize);
|
105
|
+
FUZZ_ASSERT(partialSize >= 0);
|
106
|
+
FUZZ_ASSERT_MSG(partialSize == partialCapacity, "Incorrect size");
|
107
|
+
FUZZ_ASSERT_MSG(!memcmp(data, partial, partialSize), "Corruption!");
|
108
|
+
free(partial);
|
109
|
+
}
|
50
110
|
|
51
|
-
|
52
|
-
free(
|
111
|
+
free(dstPlusLargePrefix);
|
112
|
+
free(largeDict);
|
53
113
|
free(rt);
|
54
114
|
FUZZ_dataProducer_free(producer);
|
55
115
|
|
data/ext/blockapi.c
CHANGED
@@ -188,7 +188,7 @@ aux_shouldbe_string(VALUE obj)
|
|
188
188
|
static inline size_t
|
189
189
|
aux_lz4_compressbound(VALUE src)
|
190
190
|
{
|
191
|
-
return LZ4_compressBound(RSTRING_LEN(src));
|
191
|
+
return LZ4_compressBound(rb_long2int(RSTRING_LEN(src)));
|
192
192
|
}
|
193
193
|
|
194
194
|
enum {
|
@@ -441,7 +441,7 @@ blkenc_setup(int argc, VALUE argv[], struct blockencoder *p, VALUE predict)
|
|
441
441
|
* NOTE: すぐ下で LZ4_saveDict() を実行するため、
|
442
442
|
* NOTE: p->predict のバッファ領域が保持されることはない。
|
443
443
|
*/
|
444
|
-
p->traits->loaddict(p->context, RSTRING_PTR(p->predict), RSTRING_LEN(p->predict));
|
444
|
+
p->traits->loaddict(p->context, RSTRING_PTR(p->predict), rb_long2int(RSTRING_LEN(p->predict)));
|
445
445
|
}
|
446
446
|
|
447
447
|
p->prefixsize = p->traits->savedict(p->context, p->prefix, sizeof(p->prefix));
|
@@ -492,7 +492,7 @@ blkenc_update(int argc, VALUE argv[], VALUE enc)
|
|
492
492
|
char *srcp;
|
493
493
|
size_t srcsize;
|
494
494
|
RSTRING_GETMEM(src, srcp, srcsize);
|
495
|
-
int s = p->traits->update(p->context, srcp, RSTRING_PTR(dest), srcsize, maxsize, p->level);
|
495
|
+
int s = p->traits->update(p->context, srcp, RSTRING_PTR(dest), aux_size2int(srcsize), aux_size2int(maxsize), p->level);
|
496
496
|
if (s <= 0) {
|
497
497
|
rb_raise(extlz4_eError,
|
498
498
|
"destsize too small (given destsize is %"PRIuSIZE")",
|
@@ -673,7 +673,7 @@ blkenc_s_encode(int argc, VALUE argv[], VALUE lz4)
|
|
673
673
|
aux_str_reserve(dest, maxsize);
|
674
674
|
rb_str_set_len(dest, 0);
|
675
675
|
|
676
|
-
int size = encoder(RSTRING_PTR(src), RSTRING_PTR(dest), srcsize, maxsize, level);
|
676
|
+
int size = encoder(RSTRING_PTR(src), RSTRING_PTR(dest), aux_size2int(srcsize), aux_size2int(maxsize), level);
|
677
677
|
if (size <= 0) {
|
678
678
|
rb_raise(extlz4_eError,
|
679
679
|
"failed LZ4 compress - maxsize is too small, or out of memory");
|
@@ -870,8 +870,8 @@ blkdec_update(int argc, VALUE argv[], VALUE dec)
|
|
870
870
|
const char *srcp;
|
871
871
|
size_t srcsize;
|
872
872
|
RSTRING_GETMEM(src, srcp, srcsize);
|
873
|
-
LZ4_setStreamDecode(p->context, p->dictbuf, p->dictsize);
|
874
|
-
int s = aux_LZ4_decompress_safe_continue(p->context, srcp, RSTRING_PTR(dest), srcsize, maxsize);
|
873
|
+
LZ4_setStreamDecode(p->context, p->dictbuf, aux_size2int(p->dictsize));
|
874
|
+
int s = aux_LZ4_decompress_safe_continue(p->context, srcp, RSTRING_PTR(dest), aux_size2int(srcsize), aux_size2int(maxsize));
|
875
875
|
if (s < 0) {
|
876
876
|
rb_raise(extlz4_eError,
|
877
877
|
"`max_dest_size' too small, or corrupt lz4'd data");
|
@@ -879,7 +879,7 @@ blkdec_update(int argc, VALUE argv[], VALUE dec)
|
|
879
879
|
rb_str_set_len(dest, s);
|
880
880
|
|
881
881
|
/* copy prefix */
|
882
|
-
if (s < sizeof(p->dictbuf)) {
|
882
|
+
if ((size_t)s < sizeof(p->dictbuf)) {
|
883
883
|
ssize_t discard = (p->dictsize + s) - sizeof(p->dictbuf);
|
884
884
|
if (discard > 0) {
|
885
885
|
size_t remain = p->dictsize - discard;
|
@@ -967,7 +967,7 @@ blkdec_s_decode(int argc, VALUE argv[], VALUE lz4)
|
|
967
967
|
aux_str_reserve(dest, maxsize);
|
968
968
|
rb_str_set_len(dest, 0);
|
969
969
|
|
970
|
-
int size = LZ4_decompress_safe(RSTRING_PTR(src), RSTRING_PTR(dest), RSTRING_LEN(src), maxsize);
|
970
|
+
int size = LZ4_decompress_safe(RSTRING_PTR(src), RSTRING_PTR(dest), rb_long2int(RSTRING_LEN(src)), aux_size2int(maxsize));
|
971
971
|
if (size < 0) {
|
972
972
|
rb_raise(extlz4_eError,
|
973
973
|
"failed LZ4_decompress_safe - max_dest_size is too small, or data is corrupted");
|
data/ext/extlz4.h
CHANGED
@@ -111,4 +111,16 @@ getref(VALUE obj, const rb_data_type_t *type)
|
|
111
111
|
return checkref(obj, getrefp(obj, type));
|
112
112
|
}
|
113
113
|
|
114
|
+
static inline int
|
115
|
+
aux_size2int(size_t n)
|
116
|
+
{
|
117
|
+
int m = (int)n;
|
118
|
+
|
119
|
+
if (m < 0 || (size_t)m != n) {
|
120
|
+
rb_raise(rb_eRangeError, "out of range integer conversion (size_t to int)");
|
121
|
+
}
|
122
|
+
|
123
|
+
return m;
|
124
|
+
}
|
125
|
+
|
114
126
|
#endif /* !EXTLZ4_H */
|
data/ext/frameapi.c
CHANGED
@@ -423,7 +423,7 @@ aux_read(VALUE obj, size_t size, VALUE buf)
|
|
423
423
|
if (NIL_P(AUX_FUNCALL(obj, id_read, SIZET2NUM(size), buf))) {
|
424
424
|
return Qnil;
|
425
425
|
} else {
|
426
|
-
if (RSTRING_LEN(buf) > size) {
|
426
|
+
if ((size_t)RSTRING_LEN(buf) > size) {
|
427
427
|
rb_raise(rb_eRuntimeError, "most read (%d, but expected to %d)", (int)RSTRING_LEN(buf), (int)size);
|
428
428
|
}
|
429
429
|
return buf;
|
@@ -511,7 +511,7 @@ fdec_read_fetch(VALUE dec, struct decoder *p)
|
|
511
511
|
rb_str_set_len(p->inbuf, 0);
|
512
512
|
}
|
513
513
|
|
514
|
-
while (RSTRING_LEN(p->inbuf) < p->status) {
|
514
|
+
while ((size_t)RSTRING_LEN(p->inbuf) < p->status) {
|
515
515
|
p->readbuf = aux_read(p->inport, p->status - RSTRING_LEN(p->inbuf), p->readbuf);
|
516
516
|
if (NIL_P(p->readbuf)) {
|
517
517
|
rb_raise(rb_eRuntimeError,
|
@@ -547,7 +547,7 @@ fdec_read_decode(VALUE dec, struct decoder *p, char *dest, size_t size)
|
|
547
547
|
break;
|
548
548
|
}
|
549
549
|
|
550
|
-
if (p->status > 0 && p->outoff >= RSTRING_LEN(p->outbuf)) {
|
550
|
+
if (p->status > 0 && p->outoff >= (size_t)RSTRING_LEN(p->outbuf)) {
|
551
551
|
fdec_read_fetch(dec, p);
|
552
552
|
}
|
553
553
|
|
data/ext/hashargs.c
CHANGED
@@ -11,6 +11,12 @@
|
|
11
11
|
|
12
12
|
#include "hashargs.h"
|
13
13
|
|
14
|
+
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
15
|
+
# define aux_noreturn _Noreturn
|
16
|
+
#else
|
17
|
+
# define aux_noreturn
|
18
|
+
#endif
|
19
|
+
|
14
20
|
struct rbx_scanhash_args
|
15
21
|
{
|
16
22
|
struct rbx_scanhash_arg *args;
|
@@ -18,7 +24,7 @@ struct rbx_scanhash_args
|
|
18
24
|
VALUE rest;
|
19
25
|
};
|
20
26
|
|
21
|
-
static void
|
27
|
+
aux_noreturn static void
|
22
28
|
rbx_scanhash_error(ID given, struct rbx_scanhash_arg *args, const struct rbx_scanhash_arg *end)
|
23
29
|
{
|
24
30
|
// 引数の数が㌧でもない数の場合、よくないことが起きそう。
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extlz4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dearblue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -100,13 +100,25 @@ files:
|
|
100
100
|
- contrib/lz4/build/VS2017/lz4.sln
|
101
101
|
- contrib/lz4/build/VS2017/lz4/lz4.rc
|
102
102
|
- contrib/lz4/build/VS2017/lz4/lz4.vcxproj
|
103
|
+
- contrib/lz4/build/VS2022/datagen/datagen.vcxproj
|
104
|
+
- contrib/lz4/build/VS2022/frametest/frametest.vcxproj
|
105
|
+
- contrib/lz4/build/VS2022/fullbench-dll/fullbench-dll.vcxproj
|
106
|
+
- contrib/lz4/build/VS2022/fullbench/fullbench.vcxproj
|
107
|
+
- contrib/lz4/build/VS2022/fuzzer/fuzzer.vcxproj
|
108
|
+
- contrib/lz4/build/VS2022/liblz4-dll/liblz4-dll.rc
|
109
|
+
- contrib/lz4/build/VS2022/liblz4-dll/liblz4-dll.vcxproj
|
110
|
+
- contrib/lz4/build/VS2022/liblz4/liblz4.vcxproj
|
111
|
+
- contrib/lz4/build/VS2022/lz4.sln
|
103
112
|
- contrib/lz4/build/cmake/CMakeLists.txt
|
113
|
+
- contrib/lz4/build/cmake/lz4Config.cmake.in
|
104
114
|
- contrib/lz4/lib/LICENSE
|
105
115
|
- contrib/lz4/lib/README.md
|
106
116
|
- contrib/lz4/lib/liblz4-dll.rc.in
|
107
117
|
- contrib/lz4/lib/liblz4.pc.in
|
108
118
|
- contrib/lz4/lib/lz4.c
|
109
119
|
- contrib/lz4/lib/lz4.h
|
120
|
+
- contrib/lz4/lib/lz4file.c
|
121
|
+
- contrib/lz4/lib/lz4file.h
|
110
122
|
- contrib/lz4/lib/lz4frame.c
|
111
123
|
- contrib/lz4/lib/lz4frame.h
|
112
124
|
- contrib/lz4/lib/lz4frame_static.h
|
@@ -128,13 +140,12 @@ files:
|
|
128
140
|
- contrib/lz4/ossfuzz/lz4_helpers.h
|
129
141
|
- contrib/lz4/ossfuzz/ossfuzz.sh
|
130
142
|
- contrib/lz4/ossfuzz/round_trip_frame_fuzzer.c
|
143
|
+
- contrib/lz4/ossfuzz/round_trip_frame_uncompressed_fuzzer.c
|
131
144
|
- contrib/lz4/ossfuzz/round_trip_fuzzer.c
|
132
145
|
- contrib/lz4/ossfuzz/round_trip_hc_fuzzer.c
|
133
146
|
- contrib/lz4/ossfuzz/round_trip_stream_fuzzer.c
|
134
147
|
- contrib/lz4/ossfuzz/standaloneengine.c
|
135
148
|
- contrib/lz4/ossfuzz/travisoss.sh
|
136
|
-
- contrib/lz4/tmp
|
137
|
-
- contrib/lz4/tmpsparse
|
138
149
|
- examples/frameapi.rb
|
139
150
|
- ext/blockapi.c
|
140
151
|
- ext/depend
|
@@ -176,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
187
|
- !ruby/object:Gem::Version
|
177
188
|
version: '0'
|
178
189
|
requirements: []
|
179
|
-
rubygems_version: 3.
|
190
|
+
rubygems_version: 3.4.13
|
180
191
|
signing_key:
|
181
192
|
specification_version: 4
|
182
193
|
summary: ruby bindings for LZ4
|
data/contrib/lz4/tmp
DELETED
Binary file
|
data/contrib/lz4/tmpsparse
DELETED
Binary file
|