Skip to content

Commit 7affbfc

Browse files
committed
C++: Add tests.
1 parent 6255662 commit 7affbfc

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5861,6 +5861,26 @@
58615861
| taint.cpp:483:18:483:19 | ref arg & ... | taint.cpp:483:19:483:19 | n [inner post update] | |
58625862
| taint.cpp:483:19:483:19 | n | taint.cpp:483:18:483:19 | & ... | |
58635863
| taint.cpp:483:28:483:34 | source1 | taint.cpp:483:11:483:15 | ref arg & ... | TAINT |
5864+
| taint.cpp:492:24:492:29 | source | taint.cpp:494:27:494:32 | source | |
5865+
| taint.cpp:493:22:493:29 | ,.-;:_ | taint.cpp:494:35:494:39 | delim | |
5866+
| taint.cpp:493:22:493:29 | ,.-;:_ | taint.cpp:496:7:496:11 | delim | |
5867+
| taint.cpp:494:20:494:25 | call to strtok | taint.cpp:495:7:495:15 | tokenized | |
5868+
| taint.cpp:494:27:494:32 | source | taint.cpp:494:20:494:25 | call to strtok | TAINT |
5869+
| taint.cpp:503:26:503:28 | ptr | taint.cpp:504:10:504:12 | ptr | |
5870+
| taint.cpp:503:26:503:28 | ptr | taint.cpp:505:7:505:9 | ptr | |
5871+
| taint.cpp:503:26:503:28 | ptr | taint.cpp:506:8:506:10 | ptr | |
5872+
| taint.cpp:503:36:503:41 | source | taint.cpp:504:15:504:20 | source | |
5873+
| taint.cpp:504:10:504:12 | ptr | taint.cpp:504:2:504:8 | call to _strset | |
5874+
| taint.cpp:504:10:504:12 | ref arg ptr | taint.cpp:505:7:505:9 | ptr | |
5875+
| taint.cpp:504:10:504:12 | ref arg ptr | taint.cpp:506:8:506:10 | ptr | |
5876+
| taint.cpp:504:15:504:20 | source | taint.cpp:504:2:504:8 | call to _strset | TAINT |
5877+
| taint.cpp:505:7:505:9 | ref arg ptr | taint.cpp:506:8:506:10 | ptr | |
5878+
| taint.cpp:506:8:506:10 | ptr | taint.cpp:506:7:506:10 | * ... | TAINT |
5879+
| taint.cpp:509:26:509:31 | source | taint.cpp:510:10:510:15 | source | |
5880+
| taint.cpp:509:26:509:31 | source | taint.cpp:511:7:511:12 | source | |
5881+
| taint.cpp:510:10:510:15 | ref arg source | taint.cpp:511:7:511:12 | source | |
5882+
| taint.cpp:510:10:510:15 | source | taint.cpp:510:2:510:8 | call to _strset | |
5883+
| taint.cpp:510:18:510:18 | 0 | taint.cpp:510:2:510:8 | call to _strset | TAINT |
58645884
| vector.cpp:16:43:16:49 | source1 | vector.cpp:17:26:17:32 | source1 | |
58655885
| vector.cpp:16:43:16:49 | source1 | vector.cpp:31:38:31:44 | source1 | |
58665886
| 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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,29 @@ void test_getdelim(FILE* source1) {
484484

485485
sink(line); // $ ir,ast
486486
}
487+
488+
// --- strtok ---
489+
490+
char *strtok(char *str, const char *delim);
491+
492+
void test_strtok(char *source) {
493+
const char* delim = ",.-;:_";
494+
char* tokenized = strtok(source, delim);
495+
sink(tokenized); // $ ast,ir
496+
sink(delim);
497+
}
498+
499+
// --- strset ---
500+
501+
char *_strset(char *str, int c);
502+
503+
void test_strset_1(char* ptr, char source) {
504+
_strset(ptr, source);
505+
sink(ptr);
506+
sink(*ptr); // $ MISSING: ast,ir
507+
}
508+
509+
void test_strset_2(char* source) {
510+
_strset(source, 0);
511+
sink(source); // $ ast,ir
512+
}

0 commit comments

Comments
 (0)