summaryrefslogtreecommitdiff
path: root/test/Analysis
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2011-12-05 18:58:01 +0000
committerAnna Zaks <ganna@apple.com>2011-12-05 18:58:01 +0000
commita50b7ab5af79690855af68f1fff7897291ba9535 (patch)
tree4899e1a2bd97369438bbedd24cb6419d28979b35 /test/Analysis
parent5845717880d1b0ecaf68c58093681eb18ace9237 (diff)
downloadclang-a50b7ab5af79690855af68f1fff7897291ba9535.tar.gz
[analyzer] Add a debug checker to test for tainted data.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145827 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r--test/Analysis/taint-tester.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/Analysis/taint-tester.c b/test/Analysis/taint-tester.c
new file mode 100644
index 0000000000..54480beabc
--- /dev/null
+++ b/test/Analysis/taint-tester.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.security.taint,debug.TaintTest -verify %s
+
+int scanf(const char *restrict format, ...);
+int getchar(void);
+
+#define BUFSIZE 10
+int Buffer[BUFSIZE];
+
+void bufferScanfAssignment(int x) {
+ int n;
+ int *addr = &Buffer[0];
+ scanf("%d", &n);
+ addr += n;// expected-warning {{tainted}}
+ *addr = n; // expected-warning {{tainted}}
+}