Skip to content

Commit 273e5bc

Browse files
committed
C++: Add testcase demonstrating that the model for 'strncpy' is broken.
1 parent ff3c76c commit 273e5bc

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6591,6 +6591,20 @@
65916591
| taint.cpp:702:4:702:6 | ... ++ | taint.cpp:703:8:703:8 | p | TAINT |
65926592
| taint.cpp:702:10:702:11 | * ... | taint.cpp:702:3:702:11 | ... = ... | |
65936593
| taint.cpp:702:11:702:11 | s | taint.cpp:702:10:702:11 | * ... | TAINT |
6594+
| taint.cpp:709:25:709:25 | d | taint.cpp:709:25:709:25 | d | |
6595+
| taint.cpp:709:25:709:25 | d | taint.cpp:711:10:711:10 | d | |
6596+
| taint.cpp:709:25:709:25 | d | taint.cpp:712:7:712:7 | d | |
6597+
| taint.cpp:709:34:709:34 | s | taint.cpp:709:34:709:34 | s | |
6598+
| taint.cpp:709:34:709:34 | s | taint.cpp:710:18:710:18 | s | |
6599+
| taint.cpp:709:34:709:34 | s | taint.cpp:711:13:711:13 | s | |
6600+
| taint.cpp:710:18:710:18 | ref arg s | taint.cpp:709:34:709:34 | s | |
6601+
| taint.cpp:710:18:710:18 | ref arg s | taint.cpp:711:13:711:13 | s | |
6602+
| taint.cpp:711:10:711:10 | d | taint.cpp:711:2:711:8 | call to strncpy | |
6603+
| taint.cpp:711:10:711:10 | ref arg d | taint.cpp:709:25:709:25 | d | |
6604+
| taint.cpp:711:10:711:10 | ref arg d | taint.cpp:712:7:712:7 | d | |
6605+
| taint.cpp:711:13:711:13 | s | taint.cpp:711:2:711:8 | call to strncpy | TAINT |
6606+
| taint.cpp:711:13:711:13 | s | taint.cpp:711:10:711:10 | ref arg d | TAINT |
6607+
| taint.cpp:712:7:712:7 | ref arg d | taint.cpp:709:25:709:25 | d | |
65946608
| vector.cpp:16:43:16:49 | source1 | vector.cpp:17:26:17:32 | source1 | |
65956609
| vector.cpp:16:43:16:49 | source1 | vector.cpp:31:38:31:44 | source1 | |
65966610
| vector.cpp:17:21:17:33 | call to vector | vector.cpp:19:14:19:14 | v | |

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,4 +702,12 @@ namespace strings {
702702
*p++ = *s;
703703
sink(p); // $ ast ir
704704
}
705+
}
706+
707+
char * strncpy (char *, const char *, unsigned long);
708+
709+
void test_strncpy(char* d, char* s) {
710+
argument_source(s);
711+
strncpy(d, s, 16);
712+
sink(d); // $ ast MISSING: ir
705713
}

0 commit comments

Comments
 (0)