Show More
@@ -1,184 +1,175 b'' | |||
|
1 | 1 | CC = clang |
|
2 | 2 | CXX = clang++ |
|
3 | 3 | |
|
4 | 4 | all: bdiff mpatch xdiff |
|
5 | 5 | |
|
6 | fuzzutil.o: fuzzutil.cc fuzzutil.h | |
|
7 | $(CXX) $(CXXFLAGS) -g -O1 \ | |
|
8 | -std=c++17 \ | |
|
9 | -I../../mercurial -c -o fuzzutil.o fuzzutil.cc | |
|
10 | ||
|
11 | fuzzutil-oss-fuzz.o: fuzzutil.cc fuzzutil.h | |
|
12 | $(CXX) $(CXXFLAGS) -std=c++17 \ | |
|
13 | -I../../mercurial -c -o fuzzutil-oss-fuzz.o fuzzutil.cc | |
|
14 | ||
|
15 | 6 | pyutil.o: pyutil.cc pyutil.h |
|
16 | 7 | $(CXX) $(CXXFLAGS) -g -O1 \ |
|
17 | 8 | `$$OUT/sanpy/bin/python-config --cflags` \ |
|
18 | 9 | -I../../mercurial -c -o pyutil.o pyutil.cc |
|
19 | 10 | |
|
20 | 11 | bdiff.o: ../../mercurial/bdiff.c |
|
21 | 12 | $(CC) $(CFLAGS) -fsanitize=fuzzer-no-link,address -c -o bdiff.o \ |
|
22 | 13 | ../../mercurial/bdiff.c |
|
23 | 14 | |
|
24 |
bdiff: bdiff.cc bdiff.o |
|
|
15 | bdiff: bdiff.cc bdiff.o | |
|
25 | 16 | $(CXX) $(CXXFLAGS) -DHG_FUZZER_INCLUDE_MAIN=1 -g -O1 -fsanitize=fuzzer-no-link,address \ |
|
26 | 17 | -std=c++17 \ |
|
27 |
-I../../mercurial bdiff.cc bdiff.o |
|
|
18 | -I../../mercurial bdiff.cc bdiff.o -o bdiff | |
|
28 | 19 | |
|
29 | 20 | bdiff-oss-fuzz.o: ../../mercurial/bdiff.c |
|
30 | 21 | $(CC) $(CFLAGS) -c -o bdiff-oss-fuzz.o ../../mercurial/bdiff.c |
|
31 | 22 | |
|
32 |
bdiff_fuzzer: bdiff.cc bdiff-oss-fuzz.o |
|
|
23 | bdiff_fuzzer: bdiff.cc bdiff-oss-fuzz.o | |
|
33 | 24 | $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial bdiff.cc \ |
|
34 |
bdiff-oss-fuzz.o |
|
|
25 | bdiff-oss-fuzz.o -lFuzzingEngine -o \ | |
|
35 | 26 | $$OUT/bdiff_fuzzer |
|
36 | 27 | |
|
37 | 28 | mpatch.o: ../../mercurial/mpatch.c |
|
38 | 29 | $(CC) -g -O1 -fsanitize=fuzzer-no-link,address -c -o mpatch.o \ |
|
39 | 30 | ../../mercurial/mpatch.c |
|
40 | 31 | |
|
41 | 32 | mpatch: CXXFLAGS += -std=c++17 |
|
42 |
mpatch: mpatch.cc mpatch.o |
|
|
33 | mpatch: mpatch.cc mpatch.o | |
|
43 | 34 | $(CXX) $(CXXFLAGS) -DHG_FUZZER_INCLUDE_MAIN=1 -g -O1 -fsanitize=fuzzer-no-link,address \ |
|
44 |
-I../../mercurial mpatch.cc mpatch.o |
|
|
35 | -I../../mercurial mpatch.cc mpatch.o -o mpatch | |
|
45 | 36 | |
|
46 | 37 | mpatch-oss-fuzz.o: ../../mercurial/mpatch.c |
|
47 | 38 | $(CC) $(CFLAGS) -c -o mpatch-oss-fuzz.o ../../mercurial/mpatch.c |
|
48 | 39 | |
|
49 |
mpatch_fuzzer: mpatch.cc mpatch-oss-fuzz.o |
|
|
40 | mpatch_fuzzer: mpatch.cc mpatch-oss-fuzz.o | |
|
50 | 41 | $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial mpatch.cc \ |
|
51 |
mpatch-oss-fuzz.o |
|
|
42 | mpatch-oss-fuzz.o -lFuzzingEngine -o \ | |
|
52 | 43 | $$OUT/mpatch_fuzzer |
|
53 | 44 | |
|
54 | 45 | mpatch_corpus.zip: |
|
55 | 46 | python mpatch_corpus.py $$OUT/mpatch_fuzzer_seed_corpus.zip |
|
56 | 47 | |
|
57 | 48 | x%.o: ../../mercurial/thirdparty/xdiff/x%.c ../../mercurial/thirdparty/xdiff/*.h |
|
58 | 49 | $(CC) -g -O1 -fsanitize=fuzzer-no-link,address -c \ |
|
59 | 50 | -o $@ \ |
|
60 | 51 | $< |
|
61 | 52 | |
|
62 | 53 | xdiff: CXXFLAGS += -std=c++17 |
|
63 |
xdiff: xdiff.cc xdiffi.o xprepare.o xutils.o |
|
|
54 | xdiff: xdiff.cc xdiffi.o xprepare.o xutils.o | |
|
64 | 55 | $(CXX) $(CXXFLAGS) -DHG_FUZZER_INCLUDE_MAIN=1 -g -O1 -fsanitize=fuzzer-no-link,address \ |
|
65 | 56 | -I../../mercurial xdiff.cc \ |
|
66 |
xdiffi.o xprepare.o xutils.o |
|
|
57 | xdiffi.o xprepare.o xutils.o -o xdiff | |
|
67 | 58 | |
|
68 | 59 | fuzz-x%.o: ../../mercurial/thirdparty/xdiff/x%.c ../../mercurial/thirdparty/xdiff/*.h |
|
69 | 60 | $(CC) $(CFLAGS) -c \ |
|
70 | 61 | -o $@ \ |
|
71 | 62 | $< |
|
72 | 63 | |
|
73 |
xdiff_fuzzer: xdiff.cc fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o |
|
|
64 | xdiff_fuzzer: xdiff.cc fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o | |
|
74 | 65 | $(CXX) $(CXXFLAGS) -std=c++17 -I../../mercurial xdiff.cc \ |
|
75 |
fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o |
|
|
66 | fuzz-xdiffi.o fuzz-xprepare.o fuzz-xutils.o \ | |
|
76 | 67 | -lFuzzingEngine -o $$OUT/xdiff_fuzzer |
|
77 | 68 | |
|
78 | 69 | manifest.o: ../../mercurial/cext/manifest.c |
|
79 | 70 | $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
80 | 71 | -I../../mercurial \ |
|
81 | 72 | -c -o manifest.o ../../mercurial/cext/manifest.c |
|
82 | 73 | |
|
83 | 74 | charencode.o: ../../mercurial/cext/charencode.c |
|
84 | 75 | $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
85 | 76 | -I../../mercurial \ |
|
86 | 77 | -c -o charencode.o ../../mercurial/cext/charencode.c |
|
87 | 78 | |
|
88 | 79 | parsers.o: ../../mercurial/cext/parsers.c |
|
89 | 80 | $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
90 | 81 | -I../../mercurial \ |
|
91 | 82 | -c -o parsers.o ../../mercurial/cext/parsers.c |
|
92 | 83 | |
|
93 | 84 | dirs.o: ../../mercurial/cext/dirs.c |
|
94 | 85 | $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
95 | 86 | -I../../mercurial \ |
|
96 | 87 | -c -o dirs.o ../../mercurial/cext/dirs.c |
|
97 | 88 | |
|
98 | 89 | pathencode.o: ../../mercurial/cext/pathencode.c |
|
99 | 90 | $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
100 | 91 | -I../../mercurial \ |
|
101 | 92 | -c -o pathencode.o ../../mercurial/cext/pathencode.c |
|
102 | 93 | |
|
103 | 94 | revlog.o: ../../mercurial/cext/revlog.c |
|
104 | 95 | $(CC) $(CFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
105 | 96 | -I../../mercurial \ |
|
106 | 97 | -c -o revlog.o ../../mercurial/cext/revlog.c |
|
107 | 98 | |
|
108 | 99 | dirs_fuzzer: dirs.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o |
|
109 | 100 | $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
110 | 101 | -Wno-register -Wno-macro-redefined \ |
|
111 | 102 | -I../../mercurial dirs.cc \ |
|
112 | 103 | manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ |
|
113 | 104 | -lFuzzingEngine `$$OUT/sanpy/bin/python-config --ldflags` \ |
|
114 | 105 | -o $$OUT/dirs_fuzzer |
|
115 | 106 | |
|
116 | 107 | fncache_fuzzer: fncache.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o |
|
117 | 108 | $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
118 | 109 | -Wno-register -Wno-macro-redefined \ |
|
119 | 110 | -I../../mercurial fncache.cc \ |
|
120 | 111 | manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ |
|
121 | 112 | -lFuzzingEngine `$$OUT/sanpy/bin/python-config --ldflags` \ |
|
122 | 113 | -o $$OUT/fncache_fuzzer |
|
123 | 114 | |
|
124 | 115 | jsonescapeu8fast_fuzzer: jsonescapeu8fast.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o |
|
125 | 116 | $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
126 | 117 | -Wno-register -Wno-macro-redefined \ |
|
127 | 118 | -I../../mercurial jsonescapeu8fast.cc \ |
|
128 | 119 | manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ |
|
129 | 120 | -lFuzzingEngine `$$OUT/sanpy/bin/python-config --ldflags` \ |
|
130 | 121 | -o $$OUT/jsonescapeu8fast_fuzzer |
|
131 | 122 | |
|
132 | 123 | manifest_corpus.zip: |
|
133 | 124 | python manifest_corpus.py $$OUT/manifest_fuzzer_seed_corpus.zip |
|
134 | 125 | |
|
135 | 126 | manifest_fuzzer: manifest.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o |
|
136 | 127 | $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
137 | 128 | -Wno-register -Wno-macro-redefined \ |
|
138 | 129 | -I../../mercurial manifest.cc \ |
|
139 | 130 | manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ |
|
140 | 131 | -lFuzzingEngine `$$OUT/sanpy/bin/python-config --ldflags` \ |
|
141 | 132 | -o $$OUT/manifest_fuzzer |
|
142 | 133 | |
|
143 | 134 | revlog_fuzzer: revlog.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o |
|
144 | 135 | $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
145 | 136 | -Wno-register -Wno-macro-redefined \ |
|
146 | 137 | -I../../mercurial revlog.cc \ |
|
147 | 138 | manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ |
|
148 | 139 | -lFuzzingEngine `$$OUT/sanpy/bin/python-config --ldflags` \ |
|
149 | 140 | -o $$OUT/revlog_fuzzer |
|
150 | 141 | |
|
151 | 142 | revlog_corpus.zip: |
|
152 | 143 | python revlog_corpus.py $$OUT/revlog_fuzzer_seed_corpus.zip |
|
153 | 144 | |
|
154 | 145 | dirstate_fuzzer: dirstate.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o |
|
155 | 146 | $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
156 | 147 | -Wno-register -Wno-macro-redefined \ |
|
157 | 148 | -I../../mercurial dirstate.cc \ |
|
158 | 149 | manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ |
|
159 | 150 | -lFuzzingEngine `$$OUT/sanpy/bin/python-config --ldflags` \ |
|
160 | 151 | -o $$OUT/dirstate_fuzzer |
|
161 | 152 | |
|
162 | 153 | dirstate_corpus.zip: |
|
163 | 154 | python dirstate_corpus.py $$OUT/dirstate_fuzzer_seed_corpus.zip |
|
164 | 155 | |
|
165 | 156 | fm1readmarkers_fuzzer: fm1readmarkers.cc manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o |
|
166 | 157 | $(CXX) $(CXXFLAGS) `$$OUT/sanpy/bin/python-config --cflags` \ |
|
167 | 158 | -Wno-register -Wno-macro-redefined \ |
|
168 | 159 | -I../../mercurial fm1readmarkers.cc \ |
|
169 | 160 | manifest.o charencode.o parsers.o dirs.o pathencode.o revlog.o pyutil.o \ |
|
170 | 161 | -lFuzzingEngine `$$OUT/sanpy/bin/python-config --ldflags` \ |
|
171 | 162 | -o $$OUT/fm1readmarkers_fuzzer |
|
172 | 163 | |
|
173 | 164 | fm1readmarkers_corpus.zip: |
|
174 | 165 | python fm1readmarkers_corpus.py $$OUT/fm1readmarkers_fuzzer_seed_corpus.zip |
|
175 | 166 | |
|
176 | 167 | clean: |
|
177 | 168 | $(RM) *.o *_fuzzer \ |
|
178 | 169 | bdiff \ |
|
179 | 170 | mpatch \ |
|
180 | 171 | xdiff |
|
181 | 172 | |
|
182 | 173 | oss-fuzz: bdiff_fuzzer mpatch_fuzzer mpatch_corpus.zip xdiff_fuzzer dirs_fuzzer fncache_fuzzer jsonescapeu8fast_fuzzer manifest_fuzzer manifest_corpus.zip revlog_fuzzer revlog_corpus.zip dirstate_fuzzer dirstate_corpus.zip fm1readmarkers_fuzzer fm1readmarkers_corpus.zip |
|
183 | 174 | |
|
184 | 175 | .PHONY: all clean oss-fuzz |
@@ -1,47 +1,37 b'' | |||
|
1 | 1 | #ifndef CONTRIB_FUZZ_FUZZUTIL_H |
|
2 | 2 | #define CONTRIB_FUZZ_FUZZUTIL_H |
|
3 | 3 | #include <iostream> |
|
4 | 4 | #include <memory> |
|
5 | 5 | #include <stdint.h> |
|
6 | 6 | |
|
7 | 7 | /* Try and use std::optional, but failing that assume we'll have a |
|
8 | 8 | * workable https://abseil.io/ install on the include path to get |
|
9 | 9 | * their backport of std::optional. */ |
|
10 | 10 | #ifdef __has_include |
|
11 | 11 | #if __has_include(<optional>) && __cplusplus >= 201703L |
|
12 | 12 | #include <optional> |
|
13 | 13 | #define CONTRIB_FUZZ_HAVE_STD_OPTIONAL |
|
14 | 14 | #endif |
|
15 | 15 | #endif |
|
16 | 16 | #ifdef CONTRIB_FUZZ_HAVE_STD_OPTIONAL |
|
17 | 17 | namespace contrib |
|
18 | 18 | { |
|
19 | 19 | using std::nullopt; |
|
20 | 20 | using std::optional; |
|
21 | 21 | } /* namespace contrib */ |
|
22 | 22 | #else |
|
23 | 23 | #include "third_party/absl/types/optional.h" |
|
24 | 24 | namespace contrib |
|
25 | 25 | { |
|
26 | 26 | using absl::nullopt; |
|
27 | 27 | using absl::optional; |
|
28 | 28 | } /* namespace contrib */ |
|
29 | 29 | #endif |
|
30 | 30 | |
|
31 | 31 | /* set DEBUG to 1 for a few debugging prints, or 2 for a lot */ |
|
32 | 32 | #define DEBUG 0 |
|
33 | 33 | #define LOG(level) \ |
|
34 | 34 | if (level <= DEBUG) \ |
|
35 | 35 | std::cout |
|
36 | 36 | |
|
37 | struct two_inputs { | |
|
38 | std::unique_ptr<char[]> right; | |
|
39 | size_t right_size; | |
|
40 | std::unique_ptr<char[]> left; | |
|
41 | size_t left_size; | |
|
42 | }; | |
|
43 | ||
|
44 | /* Split a non-zero-length input into two inputs. */ | |
|
45 | contrib::optional<two_inputs> SplitInputs(const uint8_t *Data, size_t Size); | |
|
46 | ||
|
47 | 37 | #endif /* CONTRIB_FUZZ_FUZZUTIL_H */ |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now