[cfe-commits] r145275 - /cfe/trunk/test/Analysis/taint-generic.c
Anna Zaks
ganna at apple.com
Mon Nov 28 12:43:40 PST 2011
Author: zaks
Date: Mon Nov 28 14:43:40 2011
New Revision: 145275
URL: http://llvm.org/viewvc/llvm-project?rev=145275&view=rev
Log:
[analyzer] Add more simple taint tests.
Modified:
cfe/trunk/test/Analysis/taint-generic.c
Modified: cfe/trunk/test/Analysis/taint-generic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/taint-generic.c?rev=145275&r1=145274&r2=145275&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/taint-generic.c (original)
+++ cfe/trunk/test/Analysis/taint-generic.c Mon Nov 28 14:43:40 2011
@@ -6,7 +6,7 @@
#define BUFSIZE 10
int Buffer[BUFSIZE];
-void bufferFoo1(void)
+void bufferScanfDirect(void)
{
int n;
scanf("%d", &n);
@@ -23,11 +23,26 @@
void bufferScanfArithmetic2(int x) {
int n;
scanf("%d", &n);
- int m = (n + 3) * x;
+ int m = 100 / (n + 3) * x;
Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
}
+void bufferScanfAssignment(int x) {
+ int n;
+ scanf("%d", &n);
+ int m;
+ if (x > 0) {
+ m = n;
+ Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
+ }
+}
+
void scanfArg() {
int t;
scanf("%d", t); // expected-warning {{Pointer argument is expected}}
}
+
+void bufferGetchar(int x) {
+ int m = getchar();
+ Buffer[m] = 1; //expected-warning {{Out of bound memory access }}
+}
More information about the cfe-commits
mailing list