diff options
author | Matt Morehouse <mascasa@google.com> | 2018-07-16 23:22:54 +0000 |
---|---|---|
committer | Matt Morehouse <mascasa@google.com> | 2018-07-16 23:22:54 +0000 |
commit | 2dad1b7d1d75e6cf0d337744c6c133c821d3dcff (patch) | |
tree | b68d67c16dc7fceb8a5788e19a705ad59b28c3b2 /test/fuzzer/SimpleTestStdio.cpp | |
parent | 37f6de13ac15a9a138a9ee0c64b1fc63b9f52029 (diff) | |
download | compiler-rt-2dad1b7d1d75e6cf0d337744c6c133c821d3dcff.tar.gz |
[libFuzzer] Avoid STL in MSan test.
Summary:
STL can cause MSan false positives if lib[std]c++ isn't instrumented
with MSan.
Reviewers: kcc
Reviewed By: kcc
Subscribers: Dor1s, llvm-commits
Differential Revision: https://reviews.llvm.org/D49404
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@337224 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/fuzzer/SimpleTestStdio.cpp')
-rw-r--r-- | test/fuzzer/SimpleTestStdio.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/fuzzer/SimpleTestStdio.cpp b/test/fuzzer/SimpleTestStdio.cpp new file mode 100644 index 000000000..ed7fe1cb3 --- /dev/null +++ b/test/fuzzer/SimpleTestStdio.cpp @@ -0,0 +1,26 @@ +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. + +// Simple test for a fuzzer. The fuzzer must find the string "Hi!". +#include <assert.h> +#include <cstdint> +#include <cstdio> +#include <cstdlib> + +static volatile int Sink; + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + assert(Data); + if (Size > 0 && Data[0] == 'H') { + Sink = 1; + if (Size > 1 && Data[1] == 'i') { + Sink = 2; + if (Size > 2 && Data[2] == '!') { + fprintf(stderr, "BINGO; Found the target, exiting\n"); + exit(0); + } + } + } + return 0; +} + |