File tree Expand file tree Collapse file tree 5 files changed +26
-31
lines changed
library-tests/dataflow/DefaultTaintTracking
query-tests/Security/CWE/CWE-190/semmle/TaintedAllocationSize Expand file tree Collapse file tree 5 files changed +26
-31
lines changed Original file line number Diff line number Diff line change @@ -99,21 +99,21 @@ void test_outparams() {
99
99
}
100
100
101
101
102
- void *memcpy (void *dst, void *src, int size);
103
102
104
- struct ContainsArray {
105
- int arr[ 16 ];
103
+
104
+ struct XY {
106
105
int x;
106
+ int y;
107
107
};
108
108
109
- void taint_array (ContainsArray *ca, int offset ) {
109
+ void taint_y (XY *xyp ) {
110
110
int tainted = getenv (" VAR" )[0 ];
111
- memcpy (ca-> arr + offset, & tainted, sizeof ( int )) ;
111
+ xyp-> y = tainted;
112
112
}
113
113
114
- void test_conflated_fields3 (int arbitrary ) {
115
- ContainsArray ca ;
116
- ca .x = 0 ;
117
- taint_array (&ca, arbitrary );
118
- sink (ca .x ); // not tainted [FALSE POSITIVE]
114
+ void test_conflated_fields3 () {
115
+ XY xy ;
116
+ xy .x = 0 ;
117
+ taint_y (&xy );
118
+ sink (xy .x ); // not tainted [FALSE POSITIVE]
119
119
}
Original file line number Diff line number Diff line change 110
110
| defaulttainttracking.cpp:97:27:97:32 | call to getenv | defaulttainttracking.cpp:98:10:98:11 | p2 |
111
111
| defaulttainttracking.cpp:97:27:97:32 | call to getenv | test_diff.cpp:1:11:1:20 | p#0 |
112
112
| defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:10:11:10:13 | p#0 |
113
- | defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:102:31:102:33 | src |
114
113
| defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:110:7:110:13 | tainted |
115
114
| defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:110:17:110:22 | call to getenv |
116
115
| defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:110:17:110:32 | (int)... |
117
116
| defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:110:17:110:32 | access to array |
118
- | defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:111:3:111:8 | call to memcpy |
119
- | defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:111:28:111:35 | & ... |
120
- | defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:111:28:111:35 | (void *)... |
117
+ | defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:111:12:111:18 | tainted |
121
118
| defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:118:11:118:11 | x |
122
119
| defaulttainttracking.cpp:110:17:110:22 | call to getenv | test_diff.cpp:2:11:2:13 | p#0 |
123
120
| globals.cpp:5:20:5:25 | call to getenv | globals.cpp:2:17:2:25 | sinkParam |
Original file line number Diff line number Diff line change 24
24
| defaulttainttracking.cpp:97:27:97:32 | call to getenv | defaulttainttracking.cpp:98:10:98:11 | p2 | IR only |
25
25
| defaulttainttracking.cpp:97:27:97:32 | call to getenv | test_diff.cpp:1:11:1:20 | p#0 | IR only |
26
26
| defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:10:11:10:13 | p#0 | IR only |
27
- | defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:102:20:102:22 | dst | AST only |
28
- | defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:111:10:111:25 | ... + ... | AST only |
29
- | defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:111:29:111:35 | tainted | AST only |
27
+ | defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:111:8:111:8 | y | AST only |
30
28
| defaulttainttracking.cpp:110:17:110:22 | call to getenv | defaulttainttracking.cpp:118:11:118:11 | x | IR only |
31
29
| defaulttainttracking.cpp:110:17:110:22 | call to getenv | test_diff.cpp:2:11:2:13 | p#0 | IR only |
32
30
| globals.cpp:13:15:13:20 | call to getenv | globals.cpp:13:5:13:11 | global1 | AST only |
Original file line number Diff line number Diff line change 1
1
edges
2
- | field_conflation.c:12:22:12:27 | call to getenv | field_conflation.c:13:10 :13:25 | Chi |
3
- | field_conflation.c:12:22:12:34 | (const char *)... | field_conflation.c:13:10 :13:25 | Chi |
4
- | field_conflation.c:13:10 :13:25 | Chi | field_conflation.c:19:15:19:17 | taint_array output argument |
2
+ | field_conflation.c:12:22:12:27 | call to getenv | field_conflation.c:13:3 :13:18 | Chi |
3
+ | field_conflation.c:12:22:12:34 | (const char *)... | field_conflation.c:13:3 :13:18 | Chi |
4
+ | field_conflation.c:13:3 :13:18 | Chi | field_conflation.c:19:15:19:17 | taint_array output argument |
5
5
| field_conflation.c:19:15:19:17 | taint_array output argument | field_conflation.c:20:10:20:13 | (unsigned long)... |
6
6
| field_conflation.c:19:15:19:17 | taint_array output argument | field_conflation.c:20:13:20:13 | x |
7
7
| field_conflation.c:19:15:19:17 | taint_array output argument | field_conflation.c:20:13:20:13 | x |
71
71
nodes
72
72
| field_conflation.c:12:22:12:27 | call to getenv | semmle.label | call to getenv |
73
73
| field_conflation.c:12:22:12:34 | (const char *)... | semmle.label | (const char *)... |
74
- | field_conflation.c:13:10 :13:25 | Chi | semmle.label | Chi |
74
+ | field_conflation.c:13:3 :13:18 | Chi | semmle.label | Chi |
75
75
| field_conflation.c:19:15:19:17 | taint_array output argument | semmle.label | taint_array output argument |
76
76
| field_conflation.c:20:10:20:13 | (unsigned long)... | semmle.label | (unsigned long)... |
77
77
| field_conflation.c:20:10:20:13 | (unsigned long)... | semmle.label | (unsigned long)... |
Original file line number Diff line number Diff line change 1
1
int atoi (const char * nptr );
2
2
void * malloc (unsigned long size );
3
3
char * getenv (const char * name );
4
- void * memcpy (void * dst , void * src , unsigned long size );
5
4
6
- struct ContainsArray {
7
- int arr [ 16 ];
5
+
6
+ struct XY {
8
7
int x ;
8
+ int y ;
9
9
};
10
10
11
- void taint_array (struct ContainsArray * ca , int offset ) {
11
+ void taint_array (struct XY * xyp ) {
12
12
int tainted = atoi (getenv ("VAR" ));
13
- memcpy ( ca -> arr + offset , & tainted , sizeof ( int )) ;
13
+ xyp -> y = tainted ;
14
14
}
15
15
16
- void test_conflated_fields3 (int arbitrary ) {
17
- struct ContainsArray ca ;
18
- ca .x = 4 ;
19
- taint_array (& ca , arbitrary );
20
- malloc (ca .x ); // not tainted [FALSE POSITIVE]
16
+ void test_conflated_fields3 (void ) {
17
+ struct XY xy ;
18
+ xy .x = 4 ;
19
+ taint_array (& xy );
20
+ malloc (xy .x ); // not tainted [FALSE POSITIVE]
21
21
}
You can’t perform that action at this time.
0 commit comments