# HG changeset patch # User Augie Fackler # Date 1573508238 18000 # Node ID 78df32a8b6f421f53870a50e44c86f2553e9fee6 # Parent dbc39f028c9f3c482147ef6c1a845459ea7963a6 fuzz: migrate xdiff fuzzer to use FuzzedDataProvider Differential Revision: https://phab.mercurial-scm.org/D7369 diff -r dbc39f028c9f -r 78df32a8b6f4 contrib/fuzz/xdiff.cc --- a/contrib/fuzz/xdiff.cc Mon Nov 11 14:48:30 2019 -0500 +++ b/contrib/fuzz/xdiff.cc Mon Nov 11 16:37:18 2019 -0500 @@ -10,7 +10,7 @@ #include #include -#include "fuzzutil.h" +#include extern "C" { @@ -27,17 +27,15 @@ if (Size > 100000) { return 0; } - auto maybe_inputs = SplitInputs(Data, Size); - if (!maybe_inputs) { - return 0; - } - auto inputs = std::move(maybe_inputs.value()); + FuzzedDataProvider provider(Data, Size); + std::string left = provider.ConsumeRandomLengthString(Size); + std::string right = provider.ConsumeRemainingBytesAsString(); mmfile_t a, b; - a.ptr = inputs.left.get(); - a.size = inputs.left_size; - b.ptr = inputs.right.get(); - b.size = inputs.right_size; + a.ptr = (char *)left.c_str(); + a.size = left.size(); + b.ptr = (char *)right.c_str(); + b.size = right.size(); xpparam_t xpp = { XDF_INDENT_HEURISTIC, /* flags */ };