Mercurial > hg-stable
changeset 43658:78df32a8b6f4
fuzz: migrate xdiff fuzzer to use FuzzedDataProvider
Differential Revision: https://phab.mercurial-scm.org/D7369
author | Augie Fackler <augie@google.com> |
---|---|
date | Mon, 11 Nov 2019 16:37:18 -0500 |
parents | dbc39f028c9f |
children | 6f5c352f41b6 |
files | contrib/fuzz/xdiff.cc |
diffstat | 1 files changed, 8 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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 <inttypes.h> #include <stdlib.h> -#include "fuzzutil.h" +#include <fuzzer/FuzzedDataProvider.h> 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 */ };