diff options
Diffstat (limited to 'test/Analysis/taint-generic.c')
-rw-r--r-- | test/Analysis/taint-generic.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/Analysis/taint-generic.c b/test/Analysis/taint-generic.c index b00372a..8ee1896 100644 --- a/test/Analysis/taint-generic.c +++ b/test/Analysis/taint-generic.c @@ -183,3 +183,32 @@ void testTaintedVLASize() { scanf("%d", &x); int vla[x]; // expected-warning{{Declared variable-length array (VLA) has tainted size}} } + +// This computation used to take a very long time. +#define longcmp(a,b,c) { \ + a -= c; a ^= c; c += b; b -= a; b ^= (a<<6) | (a >> (32-b)); a += c; c -= b; c ^= b; b += a; \ + a -= c; a ^= c; c += b; b -= a; b ^= a; a += c; c -= b; c ^= b; b += a; } + +unsigned radar11369570_hanging(const unsigned char *arr, int l) { + unsigned a, b, c; + a = b = c = 0x9899e3 + l; + while (l >= 6) { + unsigned t; + scanf("%d", &t); + a += b; + a ^= a; + a += (arr[3] + ((unsigned) arr[2] << 8) + ((unsigned) arr[1] << 16) + ((unsigned) arr[0] << 24)); + longcmp(a, t, c); + l -= 12; + } + return 5/a; // expected-warning {{Division by a tainted value, possibly zero}} +} + +// Check that we do not assert of the following code. +int SymSymExprWithDiffTypes(void* p) { + int i; + scanf("%d", &i); + int j = (i % (int)(long)p); + return 5/j; // expected-warning {{Division by a tainted value, possibly zero}} +} + |