Skip to content

Commit 8d5febf

Browse files
committed
C++: Add a couple more test cases that have been discussed.
1 parent cc170bd commit 8d5febf

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
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
@@ -1020,6 +1020,8 @@
10201020
| string.cpp:393:28:393:32 | call to begin | string.cpp:405:8:405:9 | i2 | |
10211021
| string.cpp:393:28:393:32 | call to begin | string.cpp:408:8:408:9 | i2 | |
10221022
| string.cpp:393:28:393:32 | call to begin | string.cpp:410:8:410:9 | i2 | |
1023+
| string.cpp:393:28:393:32 | call to begin | string.cpp:417:9:417:10 | i2 | |
1024+
| string.cpp:393:28:393:32 | call to begin | string.cpp:420:9:420:10 | i2 | |
10231025
| string.cpp:396:10:396:11 | i2 | string.cpp:396:12:396:12 | call to operator+ | TAINT |
10241026
| string.cpp:396:10:396:11 | ref arg i2 | string.cpp:397:10:397:11 | i2 | |
10251027
| string.cpp:396:10:396:11 | ref arg i2 | string.cpp:398:8:398:9 | i2 | |
@@ -1028,6 +1030,8 @@
10281030
| string.cpp:396:10:396:11 | ref arg i2 | string.cpp:405:8:405:9 | i2 | |
10291031
| string.cpp:396:10:396:11 | ref arg i2 | string.cpp:408:8:408:9 | i2 | |
10301032
| string.cpp:396:10:396:11 | ref arg i2 | string.cpp:410:8:410:9 | i2 | |
1033+
| string.cpp:396:10:396:11 | ref arg i2 | string.cpp:417:9:417:10 | i2 | |
1034+
| string.cpp:396:10:396:11 | ref arg i2 | string.cpp:420:9:420:10 | i2 | |
10311035
| string.cpp:396:12:396:12 | call to operator+ | string.cpp:396:8:396:8 | call to operator* | TAINT |
10321036
| string.cpp:397:10:397:11 | i2 | string.cpp:397:12:397:12 | call to operator- | TAINT |
10331037
| string.cpp:397:10:397:11 | ref arg i2 | string.cpp:398:8:398:9 | i2 | |
@@ -1036,6 +1040,8 @@
10361040
| string.cpp:397:10:397:11 | ref arg i2 | string.cpp:405:8:405:9 | i2 | |
10371041
| string.cpp:397:10:397:11 | ref arg i2 | string.cpp:408:8:408:9 | i2 | |
10381042
| string.cpp:397:10:397:11 | ref arg i2 | string.cpp:410:8:410:9 | i2 | |
1043+
| string.cpp:397:10:397:11 | ref arg i2 | string.cpp:417:9:417:10 | i2 | |
1044+
| string.cpp:397:10:397:11 | ref arg i2 | string.cpp:420:9:420:10 | i2 | |
10391045
| string.cpp:397:12:397:12 | call to operator- | string.cpp:397:8:397:8 | call to operator* | TAINT |
10401046
| string.cpp:398:8:398:9 | i2 | string.cpp:398:3:398:9 | ... = ... | |
10411047
| string.cpp:398:8:398:9 | i2 | string.cpp:399:12:399:13 | i3 | |
@@ -1074,6 +1080,20 @@
10741080
| string.cpp:414:5:414:6 | i9 | string.cpp:414:3:414:3 | call to operator-- | |
10751081
| string.cpp:414:5:414:6 | ref arg i9 | string.cpp:415:9:415:10 | i9 | |
10761082
| string.cpp:415:9:415:10 | i9 | string.cpp:415:8:415:8 | call to operator* | TAINT |
1083+
| string.cpp:417:9:417:10 | i2 | string.cpp:417:3:417:10 | ... = ... | |
1084+
| string.cpp:417:9:417:10 | i2 | string.cpp:418:10:418:12 | i10 | |
1085+
| string.cpp:417:9:417:10 | i2 | string.cpp:419:8:419:10 | i10 | |
1086+
| string.cpp:418:10:418:12 | i10 | string.cpp:418:13:418:13 | call to operator++ | |
1087+
| string.cpp:418:10:418:12 | ref arg i10 | string.cpp:419:8:419:10 | i10 | |
1088+
| string.cpp:418:13:418:13 | call to operator++ | string.cpp:418:8:418:8 | call to operator* | TAINT |
1089+
| string.cpp:419:8:419:10 | i10 | string.cpp:419:8:419:10 | call to iterator | |
1090+
| string.cpp:420:9:420:10 | i2 | string.cpp:420:3:420:10 | ... = ... | |
1091+
| string.cpp:420:9:420:10 | i2 | string.cpp:421:10:421:12 | i11 | |
1092+
| string.cpp:420:9:420:10 | i2 | string.cpp:422:8:422:10 | i11 | |
1093+
| string.cpp:421:10:421:12 | i11 | string.cpp:421:13:421:13 | call to operator-- | |
1094+
| string.cpp:421:10:421:12 | ref arg i11 | string.cpp:422:8:422:10 | i11 | |
1095+
| string.cpp:421:13:421:13 | call to operator-- | string.cpp:421:8:421:8 | call to operator* | TAINT |
1096+
| string.cpp:422:8:422:10 | i11 | string.cpp:422:8:422:10 | call to iterator | |
10771097
| string.cpp:428:17:428:20 | aa | string.cpp:428:17:428:21 | call to basic_string | TAINT |
10781098
| string.cpp:428:17:428:21 | call to basic_string | string.cpp:433:7:433:8 | s1 | |
10791099
| string.cpp:428:17:428:21 | call to basic_string | string.cpp:434:7:434:8 | s1 | |

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ void test_string_iterators() {
391391
string::iterator i1 = s1.begin();
392392

393393
string::iterator i2 = s2.begin();
394-
string::iterator i3, i4, i5, i6, i7, i8, i9;
394+
string::iterator i3, i4, i5, i6, i7, i8, i9, i10, i11;
395395

396396
sink(*(i2+1)); //tainted
397397
sink(*(i2-1)); // tainted
@@ -414,12 +414,12 @@ void test_string_iterators() {
414414
--i9;
415415
sink(*i9); // tainted
416416

417-
418-
419-
420-
421-
422-
417+
i10 = i2;
418+
sink(*(i10++)); // tainted
419+
sink(i10); // tainted
420+
i11 = i2;
421+
sink(*(i11--)); // tainted
422+
sink(i11); // tainted
423423
}
424424
}
425425

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@
133133
| string.cpp:409:8:409:8 | call to operator* | string.cpp:389:18:389:23 | call to source |
134134
| string.cpp:411:8:411:8 | call to operator* | string.cpp:389:18:389:23 | call to source |
135135
| string.cpp:415:8:415:8 | call to operator* | string.cpp:389:18:389:23 | call to source |
136+
| string.cpp:418:8:418:8 | call to operator* | string.cpp:389:18:389:23 | call to source |
137+
| string.cpp:419:8:419:10 | call to iterator | string.cpp:389:18:389:23 | call to source |
138+
| string.cpp:421:8:421:8 | call to operator* | string.cpp:389:18:389:23 | call to source |
139+
| string.cpp:422:8:422:10 | call to iterator | string.cpp:389:18:389:23 | call to source |
136140
| string.cpp:436:10:436:15 | call to insert | string.cpp:431:14:431:19 | call to source |
137141
| string.cpp:437:7:437:8 | s2 | string.cpp:431:14:431:19 | call to source |
138142
| string.cpp:449:10:449:15 | call to insert | string.cpp:449:32:449:46 | call to source |

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
| string.cpp:409:8:409:8 | string.cpp:389:18:389:23 | AST only |
6161
| string.cpp:411:8:411:8 | string.cpp:389:18:389:23 | AST only |
6262
| string.cpp:415:8:415:11 | string.cpp:389:18:389:23 | IR only |
63+
| string.cpp:418:8:418:8 | string.cpp:389:18:389:23 | AST only |
64+
| string.cpp:419:8:419:10 | string.cpp:389:18:389:23 | AST only |
65+
| string.cpp:421:8:421:8 | string.cpp:389:18:389:23 | AST only |
66+
| string.cpp:422:8:422:10 | string.cpp:389:18:389:23 | AST only |
6367
| string.cpp:436:10:436:15 | string.cpp:431:14:431:19 | AST only |
6468
| string.cpp:449:10:449:15 | string.cpp:449:32:449:46 | AST only |
6569
| string.cpp:462:10:462:15 | string.cpp:457:18:457:23 | AST only |

0 commit comments

Comments
 (0)