From b6ca45c39fd1cae93225bf517cc15b72c4da9686 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Wed, 6 May 2015 22:19:00 +0000 Subject: [PATCH] [lib/Fuzzer] rename TestOneInput to LLVMFuzzerTestOneInput to make it more unique git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236652 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LibFuzzer.rst | 10 +++++----- lib/Fuzzer/FuzzerMain.cpp | 4 ++-- lib/Fuzzer/dfsan_fuzzer_abi.list | 2 +- lib/Fuzzer/test/CounterTest.cpp | 2 +- lib/Fuzzer/test/CxxTokensTest.cpp | 2 +- lib/Fuzzer/test/FourIndependentBranchesTest.cpp | 2 +- lib/Fuzzer/test/FullCoverageSetTest.cpp | 2 +- lib/Fuzzer/test/FuzzerUnittest.cpp | 6 +++--- lib/Fuzzer/test/InfiniteTest.cpp | 2 +- lib/Fuzzer/test/NullDerefTest.cpp | 2 +- lib/Fuzzer/test/SimpleTest.cpp | 2 +- lib/Fuzzer/test/TimeoutTest.cpp | 2 +- lib/Fuzzer/test/dfsan/DFSanSimpleCmpTest.cpp | 2 +- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/LibFuzzer.rst b/docs/LibFuzzer.rst index 383f888f9f4..f848021ef13 100644 --- a/docs/LibFuzzer.rst +++ b/docs/LibFuzzer.rst @@ -20,7 +20,7 @@ This library is intended primarily for in-process coverage-guided fuzz testing optimizations options (e.g. -O0, -O1, -O2) to diversify testing. * Build a test driver using the same options as the library. The test driver is a C/C++ file containing interesting calls to the library - inside a single function ``extern "C" void TestOneInput(const uint8_t *Data, size_t Size);`` + inside a single function ``extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);`` * Link the Fuzzer, the library and the driver together into an executable using the same sanitizer options as for the library. * Collect the initial corpus of inputs for the @@ -56,7 +56,7 @@ Toy example A simple function that does something interesting if it receives the input "HI!":: cat << EOF >> test_fuzzer.cc - extern "C" void TestOneInput(const unsigned char *data, unsigned long size) { + extern "C" void LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) { if (size > 0 && data[0] == 'H') if (size > 1 && data[1] == 'I') if (size > 2 && data[2] == '!') @@ -92,7 +92,7 @@ Here we show how to use lib/Fuzzer on something real, yet simple: pcre2_:: cat << EOF > pcre_fuzzer.cc #include #include "pcre2posix.h" - extern "C" void TestOneInput(const unsigned char *data, size_t size) { + extern "C" void LLVMFuzzerTestOneInput(const unsigned char *data, size_t size) { if (size < 1) return; char *str = new char[size+1]; memcpy(str, data, size); @@ -196,7 +196,7 @@ to find Heartbleed with LibFuzzer:: assert (SSL_CTX_use_PrivateKey_file(sctx, "server.key", SSL_FILETYPE_PEM)); return 0; } - extern "C" void TestOneInput(unsigned char *Data, size_t Size) { + extern "C" void LLVMFuzzerTestOneInput(unsigned char *Data, size_t Size) { static int unused = Init(); SSL *server = SSL_new(sctx); BIO *sinbio = BIO_new(BIO_s_mem()); @@ -259,7 +259,7 @@ Periodically restart both fuzzers so that they can use each other's findings. How good is my fuzzer? ---------------------- -Once you implement your target function ``TestOneInput`` and fuzz it to death, +Once you implement your target function ``LLVMFuzzerTestOneInput`` and fuzz it to death, you will want to know whether the function or the corpus can be improved further. One easy to use metric is, of course, code coverage. You can get the coverage for your corpus like this:: diff --git a/lib/Fuzzer/FuzzerMain.cpp b/lib/Fuzzer/FuzzerMain.cpp index d0c3df3b6b5..c4dffb45d16 100644 --- a/lib/Fuzzer/FuzzerMain.cpp +++ b/lib/Fuzzer/FuzzerMain.cpp @@ -13,8 +13,8 @@ #include "FuzzerInternal.h" // This function should be defined by the user. -extern "C" void TestOneInput(const uint8_t *Data, size_t Size); +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size); int main(int argc, char **argv) { - return fuzzer::FuzzerDriver(argc, argv, TestOneInput); + return fuzzer::FuzzerDriver(argc, argv, LLVMFuzzerTestOneInput); } diff --git a/lib/Fuzzer/dfsan_fuzzer_abi.list b/lib/Fuzzer/dfsan_fuzzer_abi.list index 7da752278f7..6cc684368a6 100644 --- a/lib/Fuzzer/dfsan_fuzzer_abi.list +++ b/lib/Fuzzer/dfsan_fuzzer_abi.list @@ -9,4 +9,4 @@ fun:__sanitizer_cov_module_init=uninstrumented fun:__sanitizer_cov_module_init=discard # Don't add extra parameters to the Fuzzer callback. -fun:TestOneInput=uninstrumented +fun:LLVMFuzzerTestOneInput=uninstrumented diff --git a/lib/Fuzzer/test/CounterTest.cpp b/lib/Fuzzer/test/CounterTest.cpp index 332ccfe7b02..29ddb02ebae 100644 --- a/lib/Fuzzer/test/CounterTest.cpp +++ b/lib/Fuzzer/test/CounterTest.cpp @@ -2,7 +2,7 @@ // executed many times. #include -extern "C" void TestOneInput(const uint8_t *Data, size_t Size) { +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { int Num = 0; for (size_t i = 0; i < Size; i++) if (Data[i] == 'A' + i) diff --git a/lib/Fuzzer/test/CxxTokensTest.cpp b/lib/Fuzzer/test/CxxTokensTest.cpp index 1addccb4bf9..682ceb4f978 100644 --- a/lib/Fuzzer/test/CxxTokensTest.cpp +++ b/lib/Fuzzer/test/CxxTokensTest.cpp @@ -10,7 +10,7 @@ static void Found() { exit(1); } -extern "C" void TestOneInput(const uint8_t *Data, size_t Size) { +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { // looking for "thread_local unsigned A;" if (Size < 24) return; if (0 == memcmp(&Data[0], "thread_local", 12)) diff --git a/lib/Fuzzer/test/FourIndependentBranchesTest.cpp b/lib/Fuzzer/test/FourIndependentBranchesTest.cpp index 171668bf764..e0b7509b8d6 100644 --- a/lib/Fuzzer/test/FourIndependentBranchesTest.cpp +++ b/lib/Fuzzer/test/FourIndependentBranchesTest.cpp @@ -4,7 +4,7 @@ #include #include -extern "C" void TestOneInput(const uint8_t *Data, size_t Size) { +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { int bits = 0; if (Size > 0 && Data[0] == 'F') bits |= 1; if (Size > 1 && Data[1] == 'U') bits |= 2; diff --git a/lib/Fuzzer/test/FullCoverageSetTest.cpp b/lib/Fuzzer/test/FullCoverageSetTest.cpp index d4f8c115abc..2c6ff98db00 100644 --- a/lib/Fuzzer/test/FullCoverageSetTest.cpp +++ b/lib/Fuzzer/test/FullCoverageSetTest.cpp @@ -4,7 +4,7 @@ #include #include -extern "C" void TestOneInput(const uint8_t *Data, size_t Size) { +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { int bits = 0; if (Size > 0 && Data[0] == 'F') bits |= 1; if (Size > 1 && Data[1] == 'U') bits |= 2; diff --git a/lib/Fuzzer/test/FuzzerUnittest.cpp b/lib/Fuzzer/test/FuzzerUnittest.cpp index 368a0f2bf00..e337ca851bf 100644 --- a/lib/Fuzzer/test/FuzzerUnittest.cpp +++ b/lib/Fuzzer/test/FuzzerUnittest.cpp @@ -2,9 +2,9 @@ #include "gtest/gtest.h" #include -// For now, have TestOneInput just to make it link. -// Later we may want to make unittests that actually call TestOneInput. -extern "C" void TestOneInput(const uint8_t *Data, size_t Size) { +// For now, have LLVMFuzzerTestOneInput just to make it link. +// Later we may want to make unittests that actually call LLVMFuzzerTestOneInput. +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { abort(); } diff --git a/lib/Fuzzer/test/InfiniteTest.cpp b/lib/Fuzzer/test/InfiniteTest.cpp index dcb3030413b..7c5c8c12713 100644 --- a/lib/Fuzzer/test/InfiniteTest.cpp +++ b/lib/Fuzzer/test/InfiniteTest.cpp @@ -6,7 +6,7 @@ static volatile int Sink; -extern "C" void TestOneInput(const uint8_t *Data, size_t Size) { +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { if (Size > 0 && Data[0] == 'H') { Sink = 1; if (Size > 1 && Data[1] == 'i') { diff --git a/lib/Fuzzer/test/NullDerefTest.cpp b/lib/Fuzzer/test/NullDerefTest.cpp index 8811e386f9d..0cff6617a31 100644 --- a/lib/Fuzzer/test/NullDerefTest.cpp +++ b/lib/Fuzzer/test/NullDerefTest.cpp @@ -7,7 +7,7 @@ static volatile int Sink; static volatile int *Null = 0; -extern "C" void TestOneInput(const uint8_t *Data, size_t Size) { +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { if (Size > 0 && Data[0] == 'H') { Sink = 1; if (Size > 1 && Data[1] == 'i') { diff --git a/lib/Fuzzer/test/SimpleTest.cpp b/lib/Fuzzer/test/SimpleTest.cpp index adb90cebe86..4e3501882d0 100644 --- a/lib/Fuzzer/test/SimpleTest.cpp +++ b/lib/Fuzzer/test/SimpleTest.cpp @@ -6,7 +6,7 @@ static volatile int Sink; -extern "C" void TestOneInput(const uint8_t *Data, size_t Size) { +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { if (Size > 0 && Data[0] == 'H') { Sink = 1; if (Size > 1 && Data[1] == 'i') { diff --git a/lib/Fuzzer/test/TimeoutTest.cpp b/lib/Fuzzer/test/TimeoutTest.cpp index 23683ce866c..d541c058b64 100644 --- a/lib/Fuzzer/test/TimeoutTest.cpp +++ b/lib/Fuzzer/test/TimeoutTest.cpp @@ -6,7 +6,7 @@ static volatile int Sink; -extern "C" void TestOneInput(const uint8_t *Data, size_t Size) { +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { if (Size > 0 && Data[0] == 'H') { Sink = 1; if (Size > 1 && Data[1] == 'i') { diff --git a/lib/Fuzzer/test/dfsan/DFSanSimpleCmpTest.cpp b/lib/Fuzzer/test/dfsan/DFSanSimpleCmpTest.cpp index 11620929a42..d94d1defa00 100644 --- a/lib/Fuzzer/test/dfsan/DFSanSimpleCmpTest.cpp +++ b/lib/Fuzzer/test/dfsan/DFSanSimpleCmpTest.cpp @@ -4,7 +4,7 @@ #include #include -extern "C" void TestOneInput(const uint8_t *Data, size_t Size) { +extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { if (Size < 14) return; uint64_t x = 0; int64_t y = 0; -- 2.34.1