Debian Codegraph @

gcc/testsuite/gcc.dg/analyzer/taint-alloc-5.c

raw
1 #include "analyzer-decls.h"
2
3 struct foo
4 {
5 int num;
6 };
7
8 /* malloc with tainted size from a field. */
9
10 void * __attribute__ ((tainted_args))
11 test_1 (struct foo f)
12 {
13 __analyzer_dump_state ("taint", f.num); /* { dg-warning "state: 'tainted'" } */
14 __analyzer_dump_state ("taint", f.num * 16); /* { dg-warning "state: 'tainted'" } */
15
16 return __builtin_malloc (f.num * 16); /* { dg-warning "use of attacker-controlled value 'f\\.num \\* 16' as allocation size without upper-bounds checking" "warning" } */
17 /* { dg-message "\\(\[0-9\]+\\) use of attacker-controlled value 'f\\.num \\* 16' as allocation size without upper-bounds checking" "final event with expr" { target *-*-* } .-1 } */
18 }