From fe4ed9bd854d1230723568a8cc6289bf9da7fff7 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Tue, 9 May 2017 01:17:29 +0000 Subject: [libFuzzer] make sure the input data is not overwritten in the fuzz target (if it is -- report an error) llvm-svn: 302494 --- llvm/lib/Fuzzer/test/OverwriteInputTest.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 llvm/lib/Fuzzer/test/OverwriteInputTest.cpp (limited to 'llvm/lib/Fuzzer/test/OverwriteInputTest.cpp') diff --git a/llvm/lib/Fuzzer/test/OverwriteInputTest.cpp b/llvm/lib/Fuzzer/test/OverwriteInputTest.cpp new file mode 100644 index 00000000000..e688682346a --- /dev/null +++ b/llvm/lib/Fuzzer/test/OverwriteInputTest.cpp @@ -0,0 +1,13 @@ +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. + +// Simple test for a fuzzer. Make sure we abort if Data is overwritten. +#include +#include + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + if (Size) + *const_cast(Data) = 1; + return 0; +} + -- cgit v1.2.3