Skip to content

Commit f07d844

Browse files
committed
C++: Add a test containing missing read/store dataflow steps for smart pointers.
1 parent a23d8de commit f07d844

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,6 +3269,26 @@
32693269
| smart_pointer.cpp:65:48:65:53 | call to source | smart_pointer.cpp:65:28:65:46 | call to make_unique | TAINT |
32703270
| smart_pointer.cpp:65:58:65:58 | 0 | smart_pointer.cpp:65:28:65:46 | call to make_unique | TAINT |
32713271
| smart_pointer.cpp:66:10:66:10 | ref arg p | smart_pointer.cpp:67:10:67:10 | p | |
3272+
| smart_pointer.cpp:76:45:76:45 | p | smart_pointer.cpp:77:5:77:5 | p | |
3273+
| smart_pointer.cpp:76:45:76:45 | p | smart_pointer.cpp:78:10:78:10 | p | |
3274+
| smart_pointer.cpp:76:45:76:45 | p | smart_pointer.cpp:79:10:79:10 | p | |
3275+
| smart_pointer.cpp:76:67:76:67 | q | smart_pointer.cpp:81:5:81:5 | q | |
3276+
| smart_pointer.cpp:76:67:76:67 | q | smart_pointer.cpp:82:10:82:10 | q | |
3277+
| smart_pointer.cpp:76:67:76:67 | q | smart_pointer.cpp:83:10:83:10 | q | |
3278+
| smart_pointer.cpp:76:67:76:67 | q | smart_pointer.cpp:84:10:84:10 | q | |
3279+
| smart_pointer.cpp:77:5:77:5 | ref arg p | smart_pointer.cpp:78:10:78:10 | p | |
3280+
| smart_pointer.cpp:77:5:77:5 | ref arg p | smart_pointer.cpp:79:10:79:10 | p | |
3281+
| smart_pointer.cpp:77:5:77:19 | ... = ... | smart_pointer.cpp:77:8:77:8 | x [post update] | |
3282+
| smart_pointer.cpp:77:12:77:17 | call to source | smart_pointer.cpp:77:5:77:19 | ... = ... | |
3283+
| smart_pointer.cpp:78:10:78:10 | ref arg p | smart_pointer.cpp:79:10:79:10 | p | |
3284+
| smart_pointer.cpp:81:5:81:5 | ref arg q | smart_pointer.cpp:82:10:82:10 | q | |
3285+
| smart_pointer.cpp:81:5:81:5 | ref arg q | smart_pointer.cpp:83:10:83:10 | q | |
3286+
| smart_pointer.cpp:81:5:81:5 | ref arg q | smart_pointer.cpp:84:10:84:10 | q | |
3287+
| smart_pointer.cpp:81:5:81:22 | ... = ... | smart_pointer.cpp:81:11:81:11 | x [post update] | |
3288+
| smart_pointer.cpp:81:15:81:20 | call to source | smart_pointer.cpp:81:5:81:22 | ... = ... | |
3289+
| smart_pointer.cpp:82:10:82:10 | ref arg q | smart_pointer.cpp:83:10:83:10 | q | |
3290+
| smart_pointer.cpp:82:10:82:10 | ref arg q | smart_pointer.cpp:84:10:84:10 | q | |
3291+
| smart_pointer.cpp:83:10:83:10 | ref arg q | smart_pointer.cpp:84:10:84:10 | q | |
32723292
| standalone_iterators.cpp:39:45:39:51 | source1 | standalone_iterators.cpp:39:45:39:51 | source1 | |
32733293
| standalone_iterators.cpp:39:45:39:51 | source1 | standalone_iterators.cpp:40:11:40:17 | source1 | |
32743294
| standalone_iterators.cpp:39:45:39:51 | source1 | standalone_iterators.cpp:41:12:41:18 | source1 | |

cpp/ql/test/library-tests/dataflow/taint-tests/smart_pointer.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,21 @@ void test_shared_field_member() {
6565
std::unique_ptr<A> p = std::make_unique<A>(source(), 0);
6666
sink(p->x); // $ MISSING: ast,ir
6767
sink(p->y); // not tainted
68-
}
68+
}
69+
70+
struct B {
71+
A a1;
72+
A a2;
73+
int z;
74+
};
75+
76+
void test_operator_arrow(std::unique_ptr<A> p, std::unique_ptr<B> q) {
77+
p->x = source();
78+
sink(p->x); // $ MISSING: ast,ir
79+
sink(p->y);
80+
81+
q->a1.x = source();
82+
sink(q->a1.x); // $ MISSING: ast,ir
83+
sink(q->a1.y);
84+
sink(q->a2.x);
85+
}

0 commit comments

Comments
 (0)