diff options
Diffstat (limited to 'clang/test/Analysis/taint-diagnostic-visitor.c')
| -rw-r--r-- | clang/test/Analysis/taint-diagnostic-visitor.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/Analysis/taint-diagnostic-visitor.c b/clang/test/Analysis/taint-diagnostic-visitor.c new file mode 100644 index 00000000000..50fc0b6a4e2 --- /dev/null +++ b/clang/test/Analysis/taint-diagnostic-visitor.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.taint,core -analyzer-output=text -verify %s + +// This file is for testing enhanced diagnostics produced by the GenericTaintChecker + +int scanf(const char *restrict format, ...); +int system(const char *command); + +void taintDiagnostic() +{ + char buf[128]; + scanf("%s", buf); // expected-note {{Taint originated here}} + system(buf); // expected-warning {{Untrusted data is passed to a system call}} // expected-note {{Untrusted data is passed to a system call (CERT/STR02-C. Sanitize data passed to complex subsystems)}} +} |

