Hubert Tong | 64b60df | 2019-06-19 15:27:35 +0000 | [diff] [blame] | 1 | // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.security.taint,debug.TaintTest %s -verify -analyzer-output=sarif -o - | %normalize_sarif | diff -U1 -b %S/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif - |
Aaron Ballman | 2c0febe | 2018-11-01 18:57:38 +0000 | [diff] [blame] | 2 | #include "../Inputs/system-header-simulator.h" |
| 3 | |
| 4 | int atoi(const char *nptr); |
| 5 | |
| 6 | void f(void) { |
| 7 | char s[80]; |
| 8 | scanf("%s", s); |
| 9 | int d = atoi(s); // expected-warning {{tainted}} |
| 10 | } |
| 11 | |
| 12 | void g(void) { |
| 13 | void (*fp)(int); |
| 14 | fp(12); // expected-warning {{Called function pointer is an uninitialized pointer value}} |
| 15 | } |
| 16 | |
| 17 | int h(int i) { |
| 18 | if (i == 0) |
| 19 | return 1 / i; // expected-warning {{Division by zero}} |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | int main(void) { |
| 24 | f(); |
| 25 | g(); |
| 26 | h(0); |
| 27 | return 0; |
| 28 | } |
| 29 | |