This will make it easier to test our fuzzers outside oss-fuzz.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
This will make it easier to test our fuzzers outside oss-fuzz.
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | contrib/fuzz/bdiff.cc (5 lines) | |||
| M | contrib/fuzz/mpatch.cc (5 lines) | |||
| M | contrib/fuzz/xdiff.cc (5 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| a16354dfe6e5 | 032d207655f7 | Augie Fackler | Dec 6 2019, 3:05 PM |
| /* | /* | ||||
| * bdiff.cc - fuzzer harness for bdiff.c | * bdiff.cc - fuzzer harness for bdiff.c | ||||
| * | * | ||||
| * Copyright 2018, Google Inc. | * Copyright 2018, Google Inc. | ||||
| * | * | ||||
| * This software may be used and distributed according to the terms of | * This software may be used and distributed according to the terms of | ||||
| * the GNU General Public License, incorporated herein by reference. | * the GNU General Public License, incorporated herein by reference. | ||||
| */ | */ | ||||
| #include <memory> | #include <memory> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <fuzzer/FuzzedDataProvider.h> | #include <fuzzer/FuzzedDataProvider.h> | ||||
| extern "C" { | extern "C" { | ||||
| #include "bdiff.h" | #include "bdiff.h" | ||||
| extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) | |||||
| { | |||||
| return 0; | |||||
| } | |||||
| int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) | ||||
| { | { | ||||
| FuzzedDataProvider provider(Data, Size); | FuzzedDataProvider provider(Data, Size); | ||||
| std::string left = provider.ConsumeRandomLengthString(Size); | std::string left = provider.ConsumeRandomLengthString(Size); | ||||
| std::string right = provider.ConsumeRemainingBytesAsString(); | std::string right = provider.ConsumeRemainingBytesAsString(); | ||||
| struct bdiff_line *a, *b; | struct bdiff_line *a, *b; | ||||
| int an = bdiff_splitlines(left.c_str(), left.size(), &a); | int an = bdiff_splitlines(left.c_str(), left.size(), &a); | ||||
| /* | /* | ||||
| * mpatch.cc - fuzzer harness for mpatch.c | * mpatch.cc - fuzzer harness for mpatch.c | ||||
| * | * | ||||
| * Copyright 2018, Google Inc. | * Copyright 2018, Google Inc. | ||||
| * | * | ||||
| * This software may be used and distributed according to the terms of | * This software may be used and distributed according to the terms of | ||||
| * the GNU General Public License, incorporated herein by reference. | * the GNU General Public License, incorporated herein by reference. | ||||
| */ | */ | ||||
| #include <iostream> | #include <iostream> | ||||
| #include <memory> | #include <memory> | ||||
| #include <stdint.h> | #include <stdint.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <vector> | #include <vector> | ||||
| #include "fuzzutil.h" | #include "fuzzutil.h" | ||||
| extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) | |||||
| { | |||||
| return 0; | |||||
| } | |||||
| // To avoid having too many OOMs from the fuzzer infrastructure, we'll | // To avoid having too many OOMs from the fuzzer infrastructure, we'll | ||||
| // skip patch application if the resulting fulltext would be bigger | // skip patch application if the resulting fulltext would be bigger | ||||
| // than 10MiB. | // than 10MiB. | ||||
| #define MAX_OUTPUT_SIZE 10485760 | #define MAX_OUTPUT_SIZE 10485760 | ||||
| extern "C" { | extern "C" { | ||||
| #include "bitmanipulation.h" | #include "bitmanipulation.h" | ||||
| #include "mpatch.h" | #include "mpatch.h" | ||||
| /* | /* | ||||
| * xdiff.cc - fuzzer harness for thirdparty/xdiff | * xdiff.cc - fuzzer harness for thirdparty/xdiff | ||||
| * | * | ||||
| * Copyright 2018, Google Inc. | * Copyright 2018, Google Inc. | ||||
| * | * | ||||
| * This software may be used and distributed according to the terms of | * This software may be used and distributed according to the terms of | ||||
| * the GNU General Public License, incorporated herein by reference. | * the GNU General Public License, incorporated herein by reference. | ||||
| */ | */ | ||||
| #include "thirdparty/xdiff/xdiff.h" | #include "thirdparty/xdiff/xdiff.h" | ||||
| #include <inttypes.h> | #include <inttypes.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <fuzzer/FuzzedDataProvider.h> | #include <fuzzer/FuzzedDataProvider.h> | ||||
| extern "C" { | extern "C" { | ||||
| int LLVMFuzzerInitialize(int *argc, char ***argv) | |||||
| { | |||||
| return 0; | |||||
| } | |||||
| int hunk_consumer(long a1, long a2, long b1, long b2, void *priv) | int hunk_consumer(long a1, long a2, long b1, long b2, void *priv) | ||||
| { | { | ||||
| // TODO: probably also test returning -1 from this when things break? | // TODO: probably also test returning -1 from this when things break? | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) | int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) | ||||
| { | { | ||||