diff options
| author | Gabor Borsik <gabor.borsik@gmail.com> | 2019-09-08 19:23:43 +0000 |
|---|---|---|
| committer | Gabor Borsik <gabor.borsik@gmail.com> | 2019-09-08 19:23:43 +0000 |
| commit | 080ecafdd8b3e990e5ad19202d089c91c9c9b164 (patch) | |
| tree | 7b97ead86932f6751affd6e67748d20e4f8d0006 /clang/test/Analysis | |
| parent | aff5bee35fb36897dd5414a52c11c14d2f858822 (diff) | |
| download | bcm5719-llvm-080ecafdd8b3e990e5ad19202d089c91c9c9b164.tar.gz bcm5719-llvm-080ecafdd8b3e990e5ad19202d089c91c9c9b164.zip | |
Move prop-sink branch to monorepo.
llvm-svn: 371342
Diffstat (limited to 'clang/test/Analysis')
| -rw-r--r-- | clang/test/Analysis/taint-generic.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/clang/test/Analysis/taint-generic.c b/clang/test/Analysis/taint-generic.c index a6aae22a61f..4d933e7b75c 100644 --- a/clang/test/Analysis/taint-generic.c +++ b/clang/test/Analysis/taint-generic.c @@ -338,3 +338,45 @@ void constraintManagerShouldTreatAsOpaque(int rhs) { if (i < rhs) *(volatile int *) 0; // no-warning } + + +// Test configuration +int mySource1(); +void mySource2(int*); +void myScanf(const char*, ...); +int myPropagator(int, int*); +int mySnprintf(char*, size_t, const char*, ...); +void mySink(int, int, int); + +void testConfigurationSources1() { + int x = mySource1(); + Buffer[x] = 1; // expected-warning {{Out of bound memory access }} +} + +void testConfigurationSources2() { + int x; + mySource2(&x); + Buffer[x] = 1; // expected-warning {{Out of bound memory access }} +} + +void testConfigurationSources3() { + int x, y; + myScanf("%d %d", &x, &y); + Buffer[y] = 1; // expected-warning {{Out of bound memory access }} +} + +void testConfigurationPropagation() { + int x = mySource1(); + int y; + myPropagator(x, &y); + Buffer[y] = 1; // expected-warning {{Out of bound memory access }} +} + +void testConfigurationSinks() { + int x = mySource1(); + mySink(x, 1, 2); + // expected-warning@-1 {{Untrusted data is passed to a user-defined sink}} + mySink(1, x, 2); // no-warning + mySink(1, 2, x); + // expected-warning@-1 {{Untrusted data is passed to a user-defined sink}} +} |

