summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/fuzzer/ImplicitSignedIntegerTruncationTest.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2018-10-11 09:09:52 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2018-10-11 09:09:52 +0000
commitd32c0d1466de85f68b82cbb500d04dcedf95984f (patch)
treefd17c6c2f740c36b16b76dcd5073fc18c9bda94d /compiler-rt/test/fuzzer/ImplicitSignedIntegerTruncationTest.cpp
parentdd403575a2e2068fd278a6165bc199b037759e6b (diff)
downloadbcm5719-llvm-d32c0d1466de85f68b82cbb500d04dcedf95984f.tar.gz
bcm5719-llvm-d32c0d1466de85f68b82cbb500d04dcedf95984f.zip
[compiler-rt][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and signed checks
Summary: This is compiler-rt part. clang part is D50901. Reviewers: rsmith, vsk, filcab, Sanitizers Reviewed by: filcab Differential Revision: https://reviews.llvm.org/D50902 llvm-svn: 344231
Diffstat (limited to 'compiler-rt/test/fuzzer/ImplicitSignedIntegerTruncationTest.cpp')
-rw-r--r--compiler-rt/test/fuzzer/ImplicitSignedIntegerTruncationTest.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/compiler-rt/test/fuzzer/ImplicitSignedIntegerTruncationTest.cpp b/compiler-rt/test/fuzzer/ImplicitSignedIntegerTruncationTest.cpp
new file mode 100644
index 00000000000..cb935da0c13
--- /dev/null
+++ b/compiler-rt/test/fuzzer/ImplicitSignedIntegerTruncationTest.cpp
@@ -0,0 +1,27 @@
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+
+// Test for signed-integer-overflow.
+#include <assert.h>
+#include <climits>
+#include <cstddef>
+#include <cstdint>
+#include <cstdlib>
+#include <iostream>
+
+static volatile int Sink;
+static unsigned char Large = UINT8_MAX;
+
+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] == '!') {
+ Large = Large + 1; // 'char overflow'.
+ }
+ }
+ }
+ return 0;
+}
OpenPOWER on IntegriCloud