Skip to content

Commit b4edbe4

Browse files
authored
Merge pull request #4298 from MathiasVP/field-conflation-with-array-content
C++: Add test demonstrating field conflation after merging #4230
2 parents 4f9d2f1 + b40941b commit b4edbe4

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

cpp/ql/test/library-tests/dataflow/fields/aliasing.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,14 @@ void addressOfField() {
100100
S s_copy = s;
101101
int* px = &s_copy.m1;
102102
sink(*px); // $f-:ast $ir
103+
}
104+
105+
void taint_a_ptr(int* pa) {
106+
*pa = user_input();
107+
}
108+
109+
void test_field_conflation_array_content() {
110+
S s;
111+
taint_a_ptr(&s.m1);
112+
sink(s.m2); //$f+:ir
103113
}

cpp/ql/test/library-tests/dataflow/fields/flow-diff.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
| aliasing.cpp:79:11:79:20 | call to user_input | aliasing.cpp:80:12:80:13 | m1 | IR only |
2222
| aliasing.cpp:86:10:86:19 | call to user_input | aliasing.cpp:87:12:87:13 | m1 | IR only |
2323
| aliasing.cpp:98:10:98:19 | call to user_input | aliasing.cpp:102:8:102:10 | * ... | IR only |
24+
| aliasing.cpp:106:9:106:18 | call to user_input | aliasing.cpp:112:10:112:11 | m2 | IR only |
2425
| arrays.cpp:6:12:6:21 | call to user_input | arrays.cpp:8:8:8:13 | access to array | AST only |
2526
| arrays.cpp:15:14:15:23 | call to user_input | arrays.cpp:17:8:17:13 | access to array | AST only |
2627
| arrays.cpp:36:26:36:35 | call to user_input | arrays.cpp:38:24:38:27 | data | AST only |

cpp/ql/test/library-tests/dataflow/fields/ir-path-flow.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ edges
6464
| aliasing.cpp:98:3:98:21 | Store | aliasing.cpp:98:3:98:21 | Chi [m1] |
6565
| aliasing.cpp:98:10:98:19 | call to user_input | aliasing.cpp:98:3:98:21 | Store |
6666
| aliasing.cpp:100:14:100:14 | Store [m1] | aliasing.cpp:102:8:102:10 | * ... |
67+
| aliasing.cpp:106:3:106:20 | Chi [array content] | aliasing.cpp:111:15:111:19 | taint_a_ptr output argument [array content] |
68+
| aliasing.cpp:106:3:106:20 | Store | aliasing.cpp:106:3:106:20 | Chi [array content] |
69+
| aliasing.cpp:106:9:106:18 | call to user_input | aliasing.cpp:106:3:106:20 | Store |
70+
| aliasing.cpp:111:15:111:19 | Chi [array content] | aliasing.cpp:112:10:112:11 | m2 |
71+
| aliasing.cpp:111:15:111:19 | taint_a_ptr output argument [array content] | aliasing.cpp:111:15:111:19 | Chi [array content] |
6772
| arrays.cpp:6:12:6:21 | call to user_input | arrays.cpp:7:8:7:13 | access to array |
6873
| arrays.cpp:6:12:6:21 | call to user_input | arrays.cpp:9:8:9:11 | * ... |
6974
| arrays.cpp:6:12:6:21 | call to user_input | arrays.cpp:10:8:10:15 | * ... |
@@ -280,6 +285,12 @@ nodes
280285
| aliasing.cpp:98:10:98:19 | call to user_input | semmle.label | call to user_input |
281286
| aliasing.cpp:100:14:100:14 | Store [m1] | semmle.label | Store [m1] |
282287
| aliasing.cpp:102:8:102:10 | * ... | semmle.label | * ... |
288+
| aliasing.cpp:106:3:106:20 | Chi [array content] | semmle.label | Chi [array content] |
289+
| aliasing.cpp:106:3:106:20 | Store | semmle.label | Store |
290+
| aliasing.cpp:106:9:106:18 | call to user_input | semmle.label | call to user_input |
291+
| aliasing.cpp:111:15:111:19 | Chi [array content] | semmle.label | Chi [array content] |
292+
| aliasing.cpp:111:15:111:19 | taint_a_ptr output argument [array content] | semmle.label | taint_a_ptr output argument [array content] |
293+
| aliasing.cpp:112:10:112:11 | m2 | semmle.label | m2 |
283294
| arrays.cpp:6:12:6:21 | call to user_input | semmle.label | call to user_input |
284295
| arrays.cpp:7:8:7:13 | access to array | semmle.label | access to array |
285296
| arrays.cpp:9:8:9:11 | * ... | semmle.label | * ... |
@@ -449,6 +460,7 @@ nodes
449460
| aliasing.cpp:87:12:87:13 | m1 | aliasing.cpp:86:10:86:19 | call to user_input | aliasing.cpp:87:12:87:13 | m1 | m1 flows from $@ | aliasing.cpp:86:10:86:19 | call to user_input | call to user_input |
450461
| aliasing.cpp:93:12:93:13 | m1 | aliasing.cpp:92:12:92:21 | call to user_input | aliasing.cpp:93:12:93:13 | m1 | m1 flows from $@ | aliasing.cpp:92:12:92:21 | call to user_input | call to user_input |
451462
| aliasing.cpp:102:8:102:10 | * ... | aliasing.cpp:98:10:98:19 | call to user_input | aliasing.cpp:102:8:102:10 | * ... | * ... flows from $@ | aliasing.cpp:98:10:98:19 | call to user_input | call to user_input |
463+
| aliasing.cpp:112:10:112:11 | m2 | aliasing.cpp:106:9:106:18 | call to user_input | aliasing.cpp:112:10:112:11 | m2 | m2 flows from $@ | aliasing.cpp:106:9:106:18 | call to user_input | call to user_input |
452464
| arrays.cpp:7:8:7:13 | access to array | arrays.cpp:6:12:6:21 | call to user_input | arrays.cpp:7:8:7:13 | access to array | access to array flows from $@ | arrays.cpp:6:12:6:21 | call to user_input | call to user_input |
453465
| arrays.cpp:9:8:9:11 | * ... | arrays.cpp:6:12:6:21 | call to user_input | arrays.cpp:9:8:9:11 | * ... | * ... flows from $@ | arrays.cpp:6:12:6:21 | call to user_input | call to user_input |
454466
| arrays.cpp:10:8:10:15 | * ... | arrays.cpp:6:12:6:21 | call to user_input | arrays.cpp:10:8:10:15 | * ... | * ... flows from $@ | arrays.cpp:6:12:6:21 | call to user_input | call to user_input |

cpp/ql/test/library-tests/dataflow/fields/partial-definition-diff.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@
158158
| aliasing.cpp:92:3:92:3 | w | AST only |
159159
| aliasing.cpp:92:7:92:8 | m1 | AST only |
160160
| aliasing.cpp:98:5:98:6 | m1 | AST only |
161+
| aliasing.cpp:106:3:106:5 | * ... | AST only |
162+
| aliasing.cpp:111:15:111:19 | & ... | AST only |
163+
| aliasing.cpp:111:16:111:16 | s | AST only |
161164
| arrays.cpp:6:3:6:8 | access to array | AST only |
162165
| arrays.cpp:6:3:6:23 | arr | IR only |
163166
| arrays.cpp:15:3:15:10 | * ... | AST only |

cpp/ql/test/library-tests/dataflow/fields/partial-definition.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@
187187
| aliasing.cpp:92:7:92:8 | m1 |
188188
| aliasing.cpp:98:3:98:3 | s |
189189
| aliasing.cpp:98:5:98:6 | m1 |
190+
| aliasing.cpp:106:3:106:5 | * ... |
191+
| aliasing.cpp:111:15:111:19 | & ... |
192+
| aliasing.cpp:111:16:111:16 | s |
190193
| arrays.cpp:6:3:6:8 | access to array |
191194
| arrays.cpp:15:3:15:10 | * ... |
192195
| arrays.cpp:36:3:36:3 | o |

0 commit comments

Comments
 (0)