summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/test/OverwriteInputTest.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2017-05-09 01:17:29 +0000
committerKostya Serebryany <kcc@google.com>2017-05-09 01:17:29 +0000
commitfe4ed9bd854d1230723568a8cc6289bf9da7fff7 (patch)
treec9d6415d69ed700008c4c4783eb3cb80048411f4 /llvm/lib/Fuzzer/test/OverwriteInputTest.cpp
parent9f29914d4018c0c8ef2b7b7bceffb0d07483e89c (diff)
downloadbcm5719-llvm-fe4ed9bd854d1230723568a8cc6289bf9da7fff7.tar.gz
bcm5719-llvm-fe4ed9bd854d1230723568a8cc6289bf9da7fff7.zip
[libFuzzer] make sure the input data is not overwritten in the fuzz target (if it is -- report an error)
llvm-svn: 302494
Diffstat (limited to 'llvm/lib/Fuzzer/test/OverwriteInputTest.cpp')
-rw-r--r--llvm/lib/Fuzzer/test/OverwriteInputTest.cpp13
1 files changed, 13 insertions, 0 deletions
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 <cstdint>
+#include <iostream>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ if (Size)
+ *const_cast<uint8_t*>(Data) = 1;
+ return 0;
+}
+
OpenPOWER on IntegriCloud