equal
deleted
inserted
replaced
8 */ |
8 */ |
9 #include "thirdparty/xdiff/xdiff.h" |
9 #include "thirdparty/xdiff/xdiff.h" |
10 #include <inttypes.h> |
10 #include <inttypes.h> |
11 #include <stdlib.h> |
11 #include <stdlib.h> |
12 |
12 |
13 #include "fuzzutil.h" |
13 #include <fuzzer/FuzzedDataProvider.h> |
14 |
14 |
15 extern "C" { |
15 extern "C" { |
16 |
16 |
17 int hunk_consumer(long a1, long a2, long b1, long b2, void *priv) |
17 int hunk_consumer(long a1, long a2, long b1, long b2, void *priv) |
18 { |
18 { |
25 // Don't allow fuzzer inputs larger than 100k, since we'll just bog |
25 // Don't allow fuzzer inputs larger than 100k, since we'll just bog |
26 // down and not accomplish much. |
26 // down and not accomplish much. |
27 if (Size > 100000) { |
27 if (Size > 100000) { |
28 return 0; |
28 return 0; |
29 } |
29 } |
30 auto maybe_inputs = SplitInputs(Data, Size); |
30 FuzzedDataProvider provider(Data, Size); |
31 if (!maybe_inputs) { |
31 std::string left = provider.ConsumeRandomLengthString(Size); |
32 return 0; |
32 std::string right = provider.ConsumeRemainingBytesAsString(); |
33 } |
|
34 auto inputs = std::move(maybe_inputs.value()); |
|
35 mmfile_t a, b; |
33 mmfile_t a, b; |
36 |
34 |
37 a.ptr = inputs.left.get(); |
35 a.ptr = (char *)left.c_str(); |
38 a.size = inputs.left_size; |
36 a.size = left.size(); |
39 b.ptr = inputs.right.get(); |
37 b.ptr = (char *)right.c_str(); |
40 b.size = inputs.right_size; |
38 b.size = right.size(); |
41 xpparam_t xpp = { |
39 xpparam_t xpp = { |
42 XDF_INDENT_HEURISTIC, /* flags */ |
40 XDF_INDENT_HEURISTIC, /* flags */ |
43 }; |
41 }; |
44 xdemitconf_t xecfg = { |
42 xdemitconf_t xecfg = { |
45 XDL_EMIT_BDIFFHUNK, /* flags */ |
43 XDL_EMIT_BDIFFHUNK, /* flags */ |