| 1 |
/* Integration test of how the execution path looks for |
| 2 |
-Wanalyzer-tainted-assertion with macro-tracking enabled |
| 3 |
(the default), where the assertion macro is defined in |
| 4 |
a system header. */ |
| 5 |
|
| 6 |
/* { dg-additional-options "-fdiagnostics-show-path-depths" } */ |
| 7 |
/* { dg-additional-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */ |
| 8 |
|
| 9 |
/* An assertion macro that has a call to a __noreturn__ function. */ |
| 10 |
|
| 11 |
/* This is marked as a system header. */ |
| 12 |
#include "test-assert.h" |
| 13 |
|
| 14 |
int __attribute__((tainted_args)) |
| 15 |
test_tainted_assert (int n) |
| 16 |
{ |
| 17 |
assert (n > 0); /* { dg-warning "use of attacked-controlled value in condition for assertion \\\[CWE-617\\\] \\\[-Wanalyzer-tainted-assertion\\\]" } */ |
| 18 |
return n * n; |
| 19 |
} |
| 20 |
|
| 21 |
/* { dg-begin-multiline-output "" } |
| 22 |
assert (n > 0); |
| 23 |
^~~~~~ |
| 24 |
'test_tainted_assert': event 1 (depth 0) |
| 25 |
| |
| 26 |
| test_tainted_assert (int n) |
| 27 |
| ^~~~~~~~~~~~~~~~~~~ |
| 28 |
| | |
| 29 |
| (1) function 'test_tainted_assert' marked with '__attribute__((tainted_args))' |
| 30 |
| |
| 31 |
+--> 'test_tainted_assert': event 2 (depth 1) |
| 32 |
| |
| 33 |
| test_tainted_assert (int n) |
| 34 |
| ^~~~~~~~~~~~~~~~~~~ |
| 35 |
| | |
| 36 |
| (2) entry to 'test_tainted_assert' |
| 37 |
| |
| 38 |
'test_tainted_assert': events 3-6 (depth 1) |
| 39 |
| |
| 40 |
| |
| 41 |
| do { if (!(EXPR)) __assert_fail (#EXPR, __FILE__, __LINE__); } while (0) |
| 42 |
| ^ ~~~~~~~~~~~~~ |
| 43 |
| | | |
| 44 |
| | (5) ...to here |
| 45 |
| | (6) treating '__assert_fail' as an assertion failure handler due to '__attribute__((__noreturn__))' |
| 46 |
| (3) use of attacker-controlled value for control flow |
| 47 |
| (4) following 'true' branch (when 'n <= 0')... |
| 48 |
| |
| 49 |
{ dg-end-multiline-output "" } */ |