snappy 0.0.17 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.dockerignore +2 -0
- data/.github/workflows/main.yml +34 -0
- data/.github/workflows/publish.yml +34 -0
- data/.gitignore +2 -1
- data/.gitmodules +1 -1
- data/Dockerfile +13 -0
- data/Gemfile +4 -0
- data/README.md +29 -5
- data/Rakefile +32 -29
- data/ext/api.c +6 -1
- data/ext/extconf.rb +23 -16
- data/lib/snappy/hadoop/reader.rb +62 -0
- data/lib/snappy/hadoop/writer.rb +51 -0
- data/lib/snappy/hadoop.rb +22 -0
- data/lib/snappy/reader.rb +14 -10
- data/lib/snappy/shim.rb +1 -1
- data/lib/snappy/version.rb +1 -1
- data/lib/snappy.rb +5 -4
- data/snappy.gemspec +13 -13
- data/test/hadoop/snappy_hadoop_reader_test.rb +115 -0
- data/test/hadoop/snappy_hadoop_writer_test.rb +48 -0
- data/test/snappy_hadoop_test.rb +26 -0
- data/test/snappy_reader_test.rb +148 -0
- data/test/snappy_test.rb +95 -0
- data/test/snappy_writer_test.rb +55 -0
- data/test/test_helper.rb +7 -0
- data/test.sh +3 -0
- data/vendor/snappy/CMakeLists.txt +297 -0
- data/vendor/snappy/CONTRIBUTING.md +26 -0
- data/vendor/snappy/NEWS +40 -0
- data/vendor/snappy/{README → README.md} +27 -18
- data/vendor/snappy/cmake/SnappyConfig.cmake.in +33 -0
- data/vendor/snappy/cmake/config.h.in +62 -0
- data/vendor/snappy/docs/README.md +72 -0
- data/vendor/snappy/snappy-internal.h +22 -18
- data/vendor/snappy/snappy-stubs-internal.cc +1 -1
- data/vendor/snappy/snappy-stubs-internal.h +116 -38
- data/vendor/snappy/snappy-stubs-public.h.in +20 -46
- data/vendor/snappy/snappy-test.cc +26 -22
- data/vendor/snappy/snappy-test.h +24 -98
- data/vendor/snappy/snappy.cc +380 -183
- data/vendor/snappy/snappy.h +14 -10
- data/vendor/snappy/snappy_compress_fuzzer.cc +59 -0
- data/vendor/snappy/snappy_uncompress_fuzzer.cc +57 -0
- data/vendor/snappy/snappy_unittest.cc +236 -261
- metadata +37 -92
- data/.travis.yml +0 -26
- data/smoke.sh +0 -8
- data/test/test-snappy-reader.rb +0 -129
- data/test/test-snappy-writer.rb +0 -55
- data/test/test-snappy.rb +0 -58
- data/vendor/snappy/ChangeLog +0 -2468
- data/vendor/snappy/INSTALL +0 -370
- data/vendor/snappy/Makefile +0 -982
- data/vendor/snappy/Makefile.am +0 -26
- data/vendor/snappy/Makefile.in +0 -982
- data/vendor/snappy/aclocal.m4 +0 -9738
- data/vendor/snappy/autogen.sh +0 -12
- data/vendor/snappy/autom4te.cache/output.0 +0 -18856
- data/vendor/snappy/autom4te.cache/output.1 +0 -18852
- data/vendor/snappy/autom4te.cache/requests +0 -297
- data/vendor/snappy/autom4te.cache/traces.0 +0 -2689
- data/vendor/snappy/autom4te.cache/traces.1 +0 -714
- data/vendor/snappy/config.guess +0 -1530
- data/vendor/snappy/config.h +0 -135
- data/vendor/snappy/config.h.in +0 -134
- data/vendor/snappy/config.log +0 -1640
- data/vendor/snappy/config.status +0 -2318
- data/vendor/snappy/config.sub +0 -1773
- data/vendor/snappy/configure +0 -18852
- data/vendor/snappy/configure.ac +0 -134
- data/vendor/snappy/depcomp +0 -688
- data/vendor/snappy/install-sh +0 -527
- data/vendor/snappy/libtool +0 -10246
- data/vendor/snappy/ltmain.sh +0 -9661
- data/vendor/snappy/m4/gtest.m4 +0 -74
- data/vendor/snappy/m4/libtool.m4 +0 -8001
- data/vendor/snappy/m4/ltoptions.m4 +0 -384
- data/vendor/snappy/m4/ltsugar.m4 +0 -123
- data/vendor/snappy/m4/ltversion.m4 +0 -23
- data/vendor/snappy/m4/lt~obsolete.m4 +0 -98
- data/vendor/snappy/missing +0 -331
- data/vendor/snappy/snappy-stubs-public.h +0 -100
- data/vendor/snappy/snappy.pc +0 -10
- data/vendor/snappy/snappy.pc.in +0 -10
- data/vendor/snappy/stamp-h1 +0 -1
data/vendor/snappy/snappy.h
CHANGED
@@ -39,7 +39,7 @@
|
|
39
39
|
#ifndef THIRD_PARTY_SNAPPY_SNAPPY_H__
|
40
40
|
#define THIRD_PARTY_SNAPPY_SNAPPY_H__
|
41
41
|
|
42
|
-
#include <
|
42
|
+
#include <cstddef>
|
43
43
|
#include <string>
|
44
44
|
|
45
45
|
#include "snappy-stubs-public.h"
|
@@ -69,11 +69,12 @@ namespace snappy {
|
|
69
69
|
// Higher-level string based routines (should be sufficient for most users)
|
70
70
|
// ------------------------------------------------------------------------
|
71
71
|
|
72
|
-
// Sets "*
|
73
|
-
// Original contents of *
|
72
|
+
// Sets "*compressed" to the compressed version of "input[0,input_length-1]".
|
73
|
+
// Original contents of *compressed are lost.
|
74
74
|
//
|
75
|
-
// REQUIRES: "input[]" is not an alias of "*
|
76
|
-
size_t Compress(const char* input, size_t input_length,
|
75
|
+
// REQUIRES: "input[]" is not an alias of "*compressed".
|
76
|
+
size_t Compress(const char* input, size_t input_length,
|
77
|
+
std::string* compressed);
|
77
78
|
|
78
79
|
// Decompresses "compressed[0,compressed_length-1]" to "*uncompressed".
|
79
80
|
// Original contents of "*uncompressed" are lost.
|
@@ -82,7 +83,7 @@ namespace snappy {
|
|
82
83
|
//
|
83
84
|
// returns false if the message is corrupted and could not be decompressed
|
84
85
|
bool Uncompress(const char* compressed, size_t compressed_length,
|
85
|
-
string* uncompressed);
|
86
|
+
std::string* uncompressed);
|
86
87
|
|
87
88
|
// Decompresses "compressed" to "*uncompressed".
|
88
89
|
//
|
@@ -193,11 +194,14 @@ namespace snappy {
|
|
193
194
|
// Note that there might be older data around that is compressed with larger
|
194
195
|
// block sizes, so the decompression code should not rely on the
|
195
196
|
// non-existence of long backreferences.
|
196
|
-
static
|
197
|
-
static
|
197
|
+
static constexpr int kBlockLog = 16;
|
198
|
+
static constexpr size_t kBlockSize = 1 << kBlockLog;
|
198
199
|
|
199
|
-
static
|
200
|
-
static
|
200
|
+
static constexpr int kMinHashTableBits = 8;
|
201
|
+
static constexpr size_t kMinHashTableSize = 1 << kMinHashTableBits;
|
202
|
+
|
203
|
+
static constexpr int kMaxHashTableBits = 14;
|
204
|
+
static constexpr size_t kMaxHashTableSize = 1 << kMaxHashTableBits;
|
201
205
|
} // end namespace snappy
|
202
206
|
|
203
207
|
#endif // THIRD_PARTY_SNAPPY_SNAPPY_H__
|
@@ -0,0 +1,59 @@
|
|
1
|
+
// Copyright 2019 Google Inc. All Rights Reserved.
|
2
|
+
//
|
3
|
+
// Redistribution and use in source and binary forms, with or without
|
4
|
+
// modification, are permitted provided that the following conditions are
|
5
|
+
// met:
|
6
|
+
//
|
7
|
+
// * Redistributions of source code must retain the above copyright
|
8
|
+
// notice, this list of conditions and the following disclaimer.
|
9
|
+
// * Redistributions in binary form must reproduce the above
|
10
|
+
// copyright notice, this list of conditions and the following disclaimer
|
11
|
+
// in the documentation and/or other materials provided with the
|
12
|
+
// distribution.
|
13
|
+
// * Neither the name of Google Inc. nor the names of its
|
14
|
+
// contributors may be used to endorse or promote products derived from
|
15
|
+
// this software without specific prior written permission.
|
16
|
+
//
|
17
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
18
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
19
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
20
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
21
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
24
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
25
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
26
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
//
|
29
|
+
// libFuzzer harness for fuzzing snappy compression code.
|
30
|
+
|
31
|
+
#include <cassert>
|
32
|
+
#include <cstddef>
|
33
|
+
#include <cstdint>
|
34
|
+
#include <string>
|
35
|
+
|
36
|
+
#include "snappy.h"
|
37
|
+
|
38
|
+
// Entry point for LibFuzzer.
|
39
|
+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
40
|
+
std::string input(reinterpret_cast<const char*>(data), size);
|
41
|
+
|
42
|
+
std::string compressed;
|
43
|
+
size_t compressed_size =
|
44
|
+
snappy::Compress(input.data(), input.size(), &compressed);
|
45
|
+
|
46
|
+
(void)compressed_size; // Variable only used in debug builds.
|
47
|
+
assert(compressed_size == compressed.size());
|
48
|
+
assert(compressed.size() <= snappy::MaxCompressedLength(input.size()));
|
49
|
+
assert(snappy::IsValidCompressedBuffer(compressed.data(), compressed.size()));
|
50
|
+
|
51
|
+
std::string uncompressed_after_compress;
|
52
|
+
bool uncompress_succeeded = snappy::Uncompress(
|
53
|
+
compressed.data(), compressed.size(), &uncompressed_after_compress);
|
54
|
+
|
55
|
+
(void)uncompress_succeeded; // Variable only used in debug builds.
|
56
|
+
assert(uncompress_succeeded);
|
57
|
+
assert(input == uncompressed_after_compress);
|
58
|
+
return 0;
|
59
|
+
}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
// Copyright 2019 Google Inc. All Rights Reserved.
|
2
|
+
//
|
3
|
+
// Redistribution and use in source and binary forms, with or without
|
4
|
+
// modification, are permitted provided that the following conditions are
|
5
|
+
// met:
|
6
|
+
//
|
7
|
+
// * Redistributions of source code must retain the above copyright
|
8
|
+
// notice, this list of conditions and the following disclaimer.
|
9
|
+
// * Redistributions in binary form must reproduce the above
|
10
|
+
// copyright notice, this list of conditions and the following disclaimer
|
11
|
+
// in the documentation and/or other materials provided with the
|
12
|
+
// distribution.
|
13
|
+
// * Neither the name of Google Inc. nor the names of its
|
14
|
+
// contributors may be used to endorse or promote products derived from
|
15
|
+
// this software without specific prior written permission.
|
16
|
+
//
|
17
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
18
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
19
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
20
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
21
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
24
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
25
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
26
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
27
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
28
|
+
//
|
29
|
+
// libFuzzer harness for fuzzing snappy's decompression code.
|
30
|
+
|
31
|
+
#include <cassert>
|
32
|
+
#include <cstddef>
|
33
|
+
#include <cstdint>
|
34
|
+
#include <string>
|
35
|
+
|
36
|
+
#include "snappy.h"
|
37
|
+
|
38
|
+
// Entry point for LibFuzzer.
|
39
|
+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
40
|
+
std::string input(reinterpret_cast<const char*>(data), size);
|
41
|
+
|
42
|
+
// Avoid self-crafted decompression bombs.
|
43
|
+
size_t uncompressed_size;
|
44
|
+
constexpr size_t kMaxUncompressedSize = 1 << 20;
|
45
|
+
bool get_uncompressed_length_succeeded = snappy::GetUncompressedLength(
|
46
|
+
input.data(), input.size(), &uncompressed_size);
|
47
|
+
if (!get_uncompressed_length_succeeded ||
|
48
|
+
(uncompressed_size > kMaxUncompressedSize)) {
|
49
|
+
return 0;
|
50
|
+
}
|
51
|
+
|
52
|
+
std::string uncompressed;
|
53
|
+
// The return value of snappy::Uncompress() is ignored because decompression
|
54
|
+
// will fail on invalid inputs.
|
55
|
+
snappy::Uncompress(input.data(), input.size(), &uncompressed);
|
56
|
+
return 0;
|
57
|
+
}
|