extlz4 0.3 → 0.3.1

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.ja.md +7 -0
  3. data/README.md +3 -3
  4. data/contrib/lz4/Makefile.inc +87 -0
  5. data/contrib/lz4/NEWS +7 -0
  6. data/contrib/lz4/README.md +1 -1
  7. data/contrib/lz4/lib/README.md +3 -5
  8. data/contrib/lz4/lib/liblz4-dll.rc.in +35 -0
  9. data/contrib/lz4/lib/lz4.c +296 -182
  10. data/contrib/lz4/lib/lz4.h +125 -40
  11. data/contrib/lz4/lib/lz4frame.c +30 -6
  12. data/contrib/lz4/lib/lz4frame.h +11 -2
  13. data/contrib/lz4/lib/lz4hc.c +93 -30
  14. data/contrib/lz4/lib/lz4hc.h +3 -0
  15. data/contrib/lz4/ossfuzz/Makefile +74 -0
  16. data/contrib/lz4/ossfuzz/compress_frame_fuzzer.c +42 -0
  17. data/contrib/lz4/ossfuzz/compress_fuzzer.c +51 -0
  18. data/contrib/lz4/ossfuzz/compress_hc_fuzzer.c +57 -0
  19. data/contrib/lz4/ossfuzz/decompress_frame_fuzzer.c +67 -0
  20. data/contrib/lz4/ossfuzz/decompress_fuzzer.c +58 -0
  21. data/contrib/lz4/ossfuzz/fuzz.h +48 -0
  22. data/contrib/lz4/ossfuzz/fuzz_helpers.h +94 -0
  23. data/contrib/lz4/ossfuzz/lz4_helpers.c +51 -0
  24. data/contrib/lz4/ossfuzz/lz4_helpers.h +13 -0
  25. data/contrib/lz4/ossfuzz/ossfuzz.sh +23 -0
  26. data/contrib/lz4/ossfuzz/round_trip_frame_fuzzer.c +39 -0
  27. data/contrib/lz4/ossfuzz/round_trip_fuzzer.c +50 -0
  28. data/contrib/lz4/ossfuzz/round_trip_hc_fuzzer.c +39 -0
  29. data/contrib/lz4/ossfuzz/round_trip_stream_fuzzer.c +302 -0
  30. data/contrib/lz4/ossfuzz/standaloneengine.c +74 -0
  31. data/contrib/lz4/ossfuzz/travisoss.sh +21 -0
  32. data/ext/blockapi.c +3 -3
  33. data/ext/hashargs.c +1 -1
  34. data/lib/extlz4.rb +5 -1
  35. data/lib/extlz4/version.rb +1 -1
  36. data/test/common.rb +2 -2
  37. metadata +22 -3
@@ -0,0 +1,74 @@
1
+ #include <stdint.h>
2
+ #include <stdio.h>
3
+ #include <stdlib.h>
4
+
5
+ #include "fuzz.h"
6
+
7
+ /**
8
+ * Main procedure for standalone fuzzing engine.
9
+ *
10
+ * Reads filenames from the argument array. For each filename, read the file
11
+ * into memory and then call the fuzzing interface with the data.
12
+ */
13
+ int main(int argc, char **argv)
14
+ {
15
+ int ii;
16
+ for(ii = 1; ii < argc; ii++)
17
+ {
18
+ FILE *infile;
19
+ printf("[%s] ", argv[ii]);
20
+
21
+ /* Try and open the file. */
22
+ infile = fopen(argv[ii], "rb");
23
+ if(infile)
24
+ {
25
+ uint8_t *buffer = NULL;
26
+ size_t buffer_len;
27
+
28
+ printf("Opened.. ");
29
+
30
+ /* Get the length of the file. */
31
+ fseek(infile, 0L, SEEK_END);
32
+ buffer_len = ftell(infile);
33
+
34
+ /* Reset the file indicator to the beginning of the file. */
35
+ fseek(infile, 0L, SEEK_SET);
36
+
37
+ /* Allocate a buffer for the file contents. */
38
+ buffer = (uint8_t *)calloc(buffer_len, sizeof(uint8_t));
39
+ if(buffer)
40
+ {
41
+ /* Read all the text from the file into the buffer. */
42
+ fread(buffer, sizeof(uint8_t), buffer_len, infile);
43
+ printf("Read %zu bytes, fuzzing.. ", buffer_len);
44
+
45
+ /* Call the fuzzer with the data. */
46
+ LLVMFuzzerTestOneInput(buffer, buffer_len);
47
+
48
+ printf("complete !!");
49
+
50
+ /* Free the buffer as it's no longer needed. */
51
+ free(buffer);
52
+ buffer = NULL;
53
+ }
54
+ else
55
+ {
56
+ fprintf(stderr,
57
+ "[%s] Failed to allocate %zu bytes \n",
58
+ argv[ii],
59
+ buffer_len);
60
+ }
61
+
62
+ /* Close the file as it's no longer needed. */
63
+ fclose(infile);
64
+ infile = NULL;
65
+ }
66
+ else
67
+ {
68
+ /* Failed to open the file. Maybe wrong name or wrong permissions? */
69
+ fprintf(stderr, "[%s] Open failed. \n", argv[ii]);
70
+ }
71
+
72
+ printf("\n");
73
+ }
74
+ }
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+
3
+ set -ex
4
+
5
+ # Clone the oss-fuzz repository
6
+ git clone https://github.com/google/oss-fuzz.git /tmp/ossfuzz
7
+
8
+ if [[ ! -d /tmp/ossfuzz/projects/lz4 ]]
9
+ then
10
+ echo "Could not find the lz4 project in ossfuzz"
11
+ exit 1
12
+ fi
13
+
14
+ # Modify the oss-fuzz Dockerfile so that we're checking out the current branch on travis.
15
+ sed -i "s@https://github.com/lz4/lz4.git@-b $TRAVIS_BRANCH https://github.com/lz4/lz4.git@" /tmp/ossfuzz/projects/lz4/Dockerfile
16
+
17
+ # Try and build the fuzzers
18
+ pushd /tmp/ossfuzz
19
+ python infra/helper.py build_image --pull lz4
20
+ python infra/helper.py build_fuzzers lz4
21
+ popd
@@ -32,7 +32,7 @@ aux_LZ4_compress_fast_continue_nogvl(va_list *vp)
32
32
  static int
33
33
  aux_LZ4_compress_fast_continue(void *context, const char *src, char *dest, int srcsize, int destsize, int acceleration)
34
34
  {
35
- return (int)aux_thread_call_without_gvl(
35
+ return (int)(intptr_t)aux_thread_call_without_gvl(
36
36
  aux_LZ4_compress_fast_continue_nogvl, NULL,
37
37
  context, src, dest, srcsize, destsize, acceleration);
38
38
  }
@@ -54,7 +54,7 @@ static int
54
54
  aux_LZ4_compressHC_continue(void *context, const char *src, char *dest, int srcsize, int destsize, int acceleration__ignored__)
55
55
  {
56
56
  (void)acceleration__ignored__;
57
- return (int)aux_thread_call_without_gvl(
57
+ return (int)(intptr_t)aux_thread_call_without_gvl(
58
58
  aux_LZ4_compressHC_continue_nogvl, NULL,
59
59
  context, src, dest, srcsize, destsize);
60
60
  }
@@ -76,7 +76,7 @@ aux_LZ4_decompress_safe_continue_nogvl(va_list *vp)
76
76
  static int
77
77
  aux_LZ4_decompress_safe_continue(LZ4_streamDecode_t *context, const char *src, char *dest, int srcsize, int maxsize)
78
78
  {
79
- return (int)aux_thread_call_without_gvl(
79
+ return (int)(intptr_t)aux_thread_call_without_gvl(
80
80
  aux_LZ4_decompress_safe_continue_nogvl, NULL,
81
81
  context, src, dest, srcsize, maxsize);
82
82
  }
@@ -142,7 +142,7 @@ rbx_scanhash(VALUE hash, VALUE rest, struct rbx_scanhash_arg *args, struct rbx_s
142
142
  hash = rbx_scanhash_to_hash(hash);
143
143
  if (!NIL_P(hash) && !RHASH_EMPTY_P(hash)) {
144
144
  struct rbx_scanhash_args argset = { args, end, rest };
145
- rb_hash_foreach(hash, rbx_scanhash_foreach, (VALUE)&argset);
145
+ rb_hash_foreach(hash, (int (*)(VALUE, VALUE, VALUE))rbx_scanhash_foreach, (VALUE)&argset);
146
146
  }
147
147
 
148
148
  rbx_scanhash_check_missingkeys(args, end);
@@ -4,7 +4,11 @@ require "stringio"
4
4
 
5
5
  ver = RUBY_VERSION[/\d+\.\d+/]
6
6
  soname = File.basename(__FILE__, ".rb") << ".so"
7
- require_relative File.join(ver, soname)
7
+ begin
8
+ require_relative File.join(ver, soname)
9
+ rescue LoadError
10
+ require File.join(ver, soname)
11
+ end
8
12
 
9
13
  require_relative "extlz4/version"
10
14
 
@@ -1,3 +1,3 @@
1
1
  module LZ4
2
- VERSION = "0.3"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -14,5 +14,5 @@ SAMPLES = {
14
14
  "random (big size)" => OpenSSL::Random.random_bytes(BIGSIZE),
15
15
  }
16
16
 
17
- SAMPLES["freebsd ports index"] = File.read("/usr/ports/INDEX-10", mode: "rb") rescue nil # if on FreeBSD
18
- SAMPLES["freebsd kernel"] = File.read("/boot/kernel/kernel", mode: "rb") rescue nil # if on FreeBSD
17
+ (SAMPLES["freebsd ports index"] = File.read("/usr/ports/INDEX-12", mode: "rb")) rescue nil # if on FreeBSD
18
+ (SAMPLES["freebsd kernel"] = File.read("/boot/kernel/kernel", mode: "rb")) rescue nil # if on FreeBSD
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - dearblue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-21 00:00:00.000000000 Z
11
+ date: 2020-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -86,10 +86,12 @@ files:
86
86
  - bin/extlz4
87
87
  - contrib/lz4/INSTALL
88
88
  - contrib/lz4/LICENSE
89
+ - contrib/lz4/Makefile.inc
89
90
  - contrib/lz4/NEWS
90
91
  - contrib/lz4/README.md
91
92
  - contrib/lz4/lib/LICENSE
92
93
  - contrib/lz4/lib/README.md
94
+ - contrib/lz4/lib/liblz4-dll.rc.in
93
95
  - contrib/lz4/lib/liblz4.pc.in
94
96
  - contrib/lz4/lib/lz4.c
95
97
  - contrib/lz4/lib/lz4.h
@@ -100,6 +102,23 @@ files:
100
102
  - contrib/lz4/lib/lz4hc.h
101
103
  - contrib/lz4/lib/xxhash.c
102
104
  - contrib/lz4/lib/xxhash.h
105
+ - contrib/lz4/ossfuzz/Makefile
106
+ - contrib/lz4/ossfuzz/compress_frame_fuzzer.c
107
+ - contrib/lz4/ossfuzz/compress_fuzzer.c
108
+ - contrib/lz4/ossfuzz/compress_hc_fuzzer.c
109
+ - contrib/lz4/ossfuzz/decompress_frame_fuzzer.c
110
+ - contrib/lz4/ossfuzz/decompress_fuzzer.c
111
+ - contrib/lz4/ossfuzz/fuzz.h
112
+ - contrib/lz4/ossfuzz/fuzz_helpers.h
113
+ - contrib/lz4/ossfuzz/lz4_helpers.c
114
+ - contrib/lz4/ossfuzz/lz4_helpers.h
115
+ - contrib/lz4/ossfuzz/ossfuzz.sh
116
+ - contrib/lz4/ossfuzz/round_trip_frame_fuzzer.c
117
+ - contrib/lz4/ossfuzz/round_trip_fuzzer.c
118
+ - contrib/lz4/ossfuzz/round_trip_hc_fuzzer.c
119
+ - contrib/lz4/ossfuzz/round_trip_stream_fuzzer.c
120
+ - contrib/lz4/ossfuzz/standaloneengine.c
121
+ - contrib/lz4/ossfuzz/travisoss.sh
103
122
  - examples/frameapi.rb
104
123
  - ext/blockapi.c
105
124
  - ext/depend
@@ -142,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
161
  - !ruby/object:Gem::Version
143
162
  version: '0'
144
163
  requirements: []
145
- rubygems_version: 3.0.3
164
+ rubygems_version: 3.0.6
146
165
  signing_key:
147
166
  specification_version: 4
148
167
  summary: ruby bindings for LZ4