Show More
@@ -3,6 +3,10 b' fuzzutil.o: fuzzutil.cc fuzzutil.h' | |||||
3 | -std=c++17 \ |
|
3 | -std=c++17 \ | |
4 | -I../../mercurial -c -o fuzzutil.o fuzzutil.cc |
|
4 | -I../../mercurial -c -o fuzzutil.o fuzzutil.cc | |
5 |
|
5 | |||
|
6 | fuzzutil-oss-fuzz.o: fuzzutil.cc fuzzutil.h | |||
|
7 | $$CXX $$CXXFLAGS -std=c++17 \ | |||
|
8 | -I../../mercurial -c -o fuzzutil-oss-fuzz.o fuzzutil.cc | |||
|
9 | ||||
6 | bdiff.o: ../../mercurial/bdiff.c |
|
10 | bdiff.o: ../../mercurial/bdiff.c | |
7 | $$CC $$CFLAGS -fsanitize=fuzzer-no-link,address -c -o bdiff.o \ |
|
11 | $$CC $$CFLAGS -fsanitize=fuzzer-no-link,address -c -o bdiff.o \ | |
8 | ../../mercurial/bdiff.c |
|
12 | ../../mercurial/bdiff.c | |
@@ -15,9 +19,10 b' bdiff: bdiff.cc bdiff.o fuzzutil.o' | |||||
15 | bdiff-oss-fuzz.o: ../../mercurial/bdiff.c |
|
19 | bdiff-oss-fuzz.o: ../../mercurial/bdiff.c | |
16 | $$CC $$CFLAGS -c -o bdiff-oss-fuzz.o ../../mercurial/bdiff.c |
|
20 | $$CC $$CFLAGS -c -o bdiff-oss-fuzz.o ../../mercurial/bdiff.c | |
17 |
|
21 | |||
18 | bdiff_fuzzer: bdiff.cc bdiff-oss-fuzz.o fuzzutil.o |
|
22 | bdiff_fuzzer: bdiff.cc bdiff-oss-fuzz.o fuzzutil-oss-fuzz.o | |
19 | $$CXX $$CXXFLAGS -std=c++17 -I../../mercurial bdiff.cc \ |
|
23 | $$CXX $$CXXFLAGS -std=c++17 -I../../mercurial bdiff.cc \ | |
20 |
bdiff-oss-fuzz.o fuzzutil.o -lFuzzingEngine -o |
|
24 | bdiff-oss-fuzz.o fuzzutil-oss-fuzz.o -lFuzzingEngine -o \ | |
|
25 | $$OUT/bdiff_fuzzer | |||
21 |
|
26 | |||
22 | x%.o: ../../mercurial/thirdparty/xdiff/x%.c ../../mercurial/thirdparty/xdiff/*.h |
|
27 | x%.o: ../../mercurial/thirdparty/xdiff/x%.c ../../mercurial/thirdparty/xdiff/*.h | |
23 | $$CC -g -O1 -fsanitize=fuzzer-no-link,address -c \ |
|
28 | $$CC -g -O1 -fsanitize=fuzzer-no-link,address -c \ | |
@@ -34,9 +39,9 b' fuzz-x%.o: ../../mercurial/thirdparty/xd' | |||||
34 | -o $@ \ |
|
39 | -o $@ \ | |
35 | $< |
|
40 | $< | |
36 |
|
41 | |||
37 | xdiff_fuzzer: xdiff.cc fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o fuzzutil.o |
|
42 | xdiff_fuzzer: xdiff.cc fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o fuzzutil-oss-fuzz.o | |
38 | $$CXX $$CXXFLAGS -std=c++17 -I../../mercurial xdiff.cc \ |
|
43 | $$CXX $$CXXFLAGS -std=c++17 -I../../mercurial xdiff.cc \ | |
39 | fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o fuzzutil.o \ |
|
44 | fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o fuzzutil-oss-fuzz.o \ | |
40 | -lFuzzingEngine -o $$OUT/xdiff_fuzzer |
|
45 | -lFuzzingEngine -o $$OUT/xdiff_fuzzer | |
41 |
|
46 | |||
42 | all: bdiff xdiff |
|
47 | all: bdiff xdiff |
@@ -2,10 +2,10 b'' | |||||
2 |
|
2 | |||
3 | #include <utility> |
|
3 | #include <utility> | |
4 |
|
4 | |||
5 |
|
|
5 | contrib::optional<two_inputs> SplitInputs(const uint8_t *Data, size_t Size) | |
6 | { |
|
6 | { | |
7 | if (!Size) { |
|
7 | if (!Size) { | |
8 |
return |
|
8 | return contrib::nullopt; | |
9 | } |
|
9 | } | |
10 | // figure out a random point in [0, Size] to split our input. |
|
10 | // figure out a random point in [0, Size] to split our input. | |
11 | size_t left_size = (Data[0] / 255.0) * (Size - 1); |
|
11 | size_t left_size = (Data[0] / 255.0) * (Size - 1); |
@@ -2,8 +2,31 b'' | |||||
2 | #define CONTRIB_FUZZ_FUZZUTIL_H |
|
2 | #define CONTRIB_FUZZ_FUZZUTIL_H | |
3 | #include <iostream> |
|
3 | #include <iostream> | |
4 | #include <memory> |
|
4 | #include <memory> | |
|
5 | #include <stdint.h> | |||
|
6 | ||||
|
7 | /* Try and use std::optional, but failing that assume we'll have a | |||
|
8 | * workable https://abseil.io/ install on the include path to get | |||
|
9 | * their backport of std::optional. */ | |||
|
10 | #ifdef __has_include | |||
|
11 | #if __has_include(<optional>) && __cplusplus >= 201703L | |||
5 | #include <optional> |
|
12 | #include <optional> | |
6 | #include <stdint.h> |
|
13 | #define CONTRIB_FUZZ_HAVE_STD_OPTIONAL | |
|
14 | #endif | |||
|
15 | #endif | |||
|
16 | #ifdef CONTRIB_FUZZ_HAVE_STD_OPTIONAL | |||
|
17 | namespace contrib | |||
|
18 | { | |||
|
19 | using std::nullopt; | |||
|
20 | using std::optional; | |||
|
21 | } /* namespace contrib */ | |||
|
22 | #else | |||
|
23 | #include "third_party/absl/types/optional.h" | |||
|
24 | namespace contrib | |||
|
25 | { | |||
|
26 | using absl::nullopt; | |||
|
27 | using absl::optional; | |||
|
28 | } /* namespace contrib */ | |||
|
29 | #endif | |||
7 |
|
30 | |||
8 | /* set DEBUG to 1 for a few debugging prints, or 2 for a lot */ |
|
31 | /* set DEBUG to 1 for a few debugging prints, or 2 for a lot */ | |
9 | #define DEBUG 0 |
|
32 | #define DEBUG 0 | |
@@ -19,6 +42,6 b' struct two_inputs {' | |||||
19 | }; |
|
42 | }; | |
20 |
|
43 | |||
21 | /* Split a non-zero-length input into two inputs. */ |
|
44 | /* Split a non-zero-length input into two inputs. */ | |
22 |
|
|
45 | contrib::optional<two_inputs> SplitInputs(const uint8_t *Data, size_t Size); | |
23 |
|
46 | |||
24 | #endif /* CONTRIB_FUZZ_FUZZUTIL_H */ |
|
47 | #endif /* CONTRIB_FUZZ_FUZZUTIL_H */ |
General Comments 0
You need to be logged in to leave comments.
Login now