aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Fuzzer/test/CustomMutatorTest.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-02-13 06:24:18 +0000
committerKostya Serebryany <kcc@google.com>2016-02-13 06:24:18 +0000
commit1deb0498f520fc1afc4540c5fa73398caffaeede (patch)
tree8768a32b64f4025a53b719e8eb826a2b1588f1ed /llvm/lib/Fuzzer/test/CustomMutatorTest.cpp
parent29c55dcbde10200ea507dda6fc0be1caf6f86e77 (diff)
downloadllvm-1deb0498f520fc1afc4540c5fa73398caffaeede.zip
llvm-1deb0498f520fc1afc4540c5fa73398caffaeede.tar.gz
llvm-1deb0498f520fc1afc4540c5fa73398caffaeede.tar.bz2
[libFuzzer] don't require seed in fuzzer::Mutate, instead use the global Fuzzer object for fuzzer::Mutate. This makes custom mutators fast
llvm-svn: 260810
Diffstat (limited to 'llvm/lib/Fuzzer/test/CustomMutatorTest.cpp')
-rw-r--r--llvm/lib/Fuzzer/test/CustomMutatorTest.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/Fuzzer/test/CustomMutatorTest.cpp b/llvm/lib/Fuzzer/test/CustomMutatorTest.cpp
index 84077d7..ef4851e 100644
--- a/llvm/lib/Fuzzer/test/CustomMutatorTest.cpp
+++ b/llvm/lib/Fuzzer/test/CustomMutatorTest.cpp
@@ -7,11 +7,19 @@
#include "FuzzerInterface.h"
+static volatile int Sink;
+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
assert(Data);
- if (Size > 0 && Data[0] == 'F') {
- std::cout << "BINGO; Found the target, exiting\n";
- exit(1);
+ if (Size > 0 && Data[0] == 'H') {
+ Sink = 1;
+ if (Size > 1 && Data[1] == 'i') {
+ Sink = 2;
+ if (Size > 2 && Data[2] == '!') {
+ std::cout << "BINGO; Found the target, exiting\n";
+ exit(1);
+ }
+ }
}
return 0;
}
@@ -23,5 +31,5 @@ extern "C" size_t LLVMFuzzerCustomMutator(uint8_t *Data, size_t Size,
std::cerr << "In LLVMFuzzerCustomMutator\n";
Printed = true;
}
- return fuzzer::Mutate(Data, Size, MaxSize, Seed);
+ return fuzzer::Mutate(Data, Size, MaxSize);
}