From: Kostya Serebryany Date: Fri, 17 Mar 2017 01:33:16 +0000 (+0000) Subject: [libFuzzer] add a test with two different bugs X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ee36bcf1101d6def7da229dc16627ddb90cd8f0;p=llvm [libFuzzer] add a test with two different bugs git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298030 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Fuzzer/test/CMakeLists.txt b/lib/Fuzzer/test/CMakeLists.txt index ab4ae92c1f4..2a31a801f9d 100644 --- a/lib/Fuzzer/test/CMakeLists.txt +++ b/lib/Fuzzer/test/CMakeLists.txt @@ -128,6 +128,7 @@ set(Tests TimeoutTest TimeoutEmptyTest TraceMallocTest + TwoDifferentBugsTest ) if(APPLE OR MSVC) diff --git a/lib/Fuzzer/test/TwoDifferentBugsTest.cpp b/lib/Fuzzer/test/TwoDifferentBugsTest.cpp new file mode 100644 index 00000000000..42c0d192ba8 --- /dev/null +++ b/lib/Fuzzer/test/TwoDifferentBugsTest.cpp @@ -0,0 +1,22 @@ +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. + +// Simple test for a fuzzer. This test may trigger two different bugs. +#include +#include +#include +#include + +static volatile int *Null = 0; + +void Foo() { Null[1] = 0; } +void Bar() { Null[2] = 0; } + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + if (Size < 10 && Data[0] == 'H') + Foo(); + if (Size >= 10 && Data[0] == 'H') + Bar(); + return 0; +} +