Skip to content

Commit 3cca844

Browse files
committed
C++: Add memcpy(vector test.
1 parent 227bf91 commit 3cca844

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7038,3 +7038,24 @@
70387038
| vector.cpp:399:33:399:35 | i11 [post update] | vector.cpp:400:7:400:9 | v11 | |
70397039
| vector.cpp:399:33:399:35 | i11 [post update] | vector.cpp:401:1:401:1 | v11 | |
70407040
| vector.cpp:400:7:400:9 | ref arg v11 | vector.cpp:401:1:401:1 | v11 | |
7041+
| vector.cpp:407:21:407:24 | call to vector | vector.cpp:411:7:411:7 | v | |
7042+
| vector.cpp:407:21:407:24 | call to vector | vector.cpp:412:10:412:10 | v | |
7043+
| vector.cpp:407:21:407:24 | call to vector | vector.cpp:413:7:413:7 | v | |
7044+
| vector.cpp:407:21:407:24 | call to vector | vector.cpp:414:1:414:1 | v | |
7045+
| vector.cpp:408:10:408:15 | call to source | vector.cpp:412:17:412:17 | s | |
7046+
| vector.cpp:409:9:409:10 | 0 | vector.cpp:412:12:412:12 | i | |
7047+
| vector.cpp:411:7:411:7 | ref arg v | vector.cpp:412:10:412:10 | v | |
7048+
| vector.cpp:411:7:411:7 | ref arg v | vector.cpp:413:7:413:7 | v | |
7049+
| vector.cpp:411:7:411:7 | ref arg v | vector.cpp:414:1:414:1 | v | |
7050+
| vector.cpp:412:9:412:13 | & ... | vector.cpp:412:2:412:7 | call to memcpy | |
7051+
| vector.cpp:412:9:412:13 | ref arg & ... | vector.cpp:412:11:412:11 | call to operator[] [inner post update] | |
7052+
| vector.cpp:412:10:412:10 | ref arg v | vector.cpp:413:7:413:7 | v | |
7053+
| vector.cpp:412:10:412:10 | ref arg v | vector.cpp:414:1:414:1 | v | |
7054+
| vector.cpp:412:10:412:10 | v | vector.cpp:412:11:412:11 | call to operator[] | TAINT |
7055+
| vector.cpp:412:11:412:11 | call to operator[] | vector.cpp:412:9:412:13 | & ... | |
7056+
| vector.cpp:412:11:412:11 | call to operator[] [inner post update] | vector.cpp:412:10:412:10 | ref arg v | TAINT |
7057+
| vector.cpp:412:16:412:17 | & ... | vector.cpp:412:2:412:7 | call to memcpy | TAINT |
7058+
| vector.cpp:412:16:412:17 | & ... | vector.cpp:412:9:412:13 | ref arg & ... | TAINT |
7059+
| vector.cpp:412:17:412:17 | s | vector.cpp:412:9:412:13 | ref arg & ... | |
7060+
| vector.cpp:412:17:412:17 | s | vector.cpp:412:16:412:17 | & ... | |
7061+
| vector.cpp:413:7:413:7 | ref arg v | vector.cpp:414:1:414:1 | v | |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,3 +653,4 @@
653653
| vector.cpp:392:7:392:8 | v9 | vector.cpp:330:10:330:15 | call to source |
654654
| vector.cpp:392:7:392:8 | v9 | vector.cpp:389:8:389:13 | call to source |
655655
| vector.cpp:400:7:400:9 | v11 | vector.cpp:399:38:399:43 | call to source |
656+
| vector.cpp:413:7:413:7 | v | vector.cpp:408:10:408:15 | call to source |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,4 @@
379379
| vector.cpp:392:7:392:8 | vector.cpp:330:10:330:15 | AST only |
380380
| vector.cpp:392:7:392:8 | vector.cpp:389:8:389:13 | AST only |
381381
| vector.cpp:400:7:400:9 | vector.cpp:399:38:399:43 | AST only |
382+
| vector.cpp:413:7:413:7 | vector.cpp:408:10:408:15 | AST only |

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,3 +399,16 @@ void test_vector_output_iterator(int b) {
399399
vector_iterator_assign_wrapper(i11, source());
400400
sink(v11); // tainted [NOT DETECTED by IR]
401401
}
402+
403+
void *memcpy(void *s1, const void *s2, size_t n);
404+
405+
void test_vector_memcpy()
406+
{
407+
std::vector<int> v(100);
408+
int s = source();
409+
int i = 0;
410+
411+
sink(v);
412+
memcpy(&v[i], &s, sizeof(int));
413+
sink(v); // tainted [NOT DETECTED by IR]
414+
}

0 commit comments

Comments
 (0)