Skip to content

Commit bbb69d5

Browse files
authored
Merge pull request github#3188 from geoffw0/swap4
C++: Add a user defined swap function to taint tests.
2 parents 8e89c37 + 7a98919 commit bbb69d5

File tree

5 files changed

+48
-1
lines changed

5 files changed

+48
-1
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,3 +512,20 @@
512512
| taint.cpp:444:7:444:7 | d [post update] | taint.cpp:447:7:447:7 | d | |
513513
| taint.cpp:445:2:445:2 | d [post update] | taint.cpp:446:7:446:7 | d | |
514514
| taint.cpp:445:2:445:2 | d [post update] | taint.cpp:447:7:447:7 | d | |
515+
| taint.cpp:452:16:452:16 | a | taint.cpp:454:10:454:10 | a | |
516+
| taint.cpp:452:24:452:24 | b | taint.cpp:455:6:455:6 | b | |
517+
| taint.cpp:454:10:454:10 | a | taint.cpp:456:6:456:6 | c | |
518+
| taint.cpp:455:6:455:6 | b | taint.cpp:452:16:452:16 | a | |
519+
| taint.cpp:455:6:455:6 | b | taint.cpp:455:2:455:6 | ... = ... | |
520+
| taint.cpp:456:6:456:6 | c | taint.cpp:452:24:452:24 | b | |
521+
| taint.cpp:456:6:456:6 | c | taint.cpp:456:2:456:6 | ... = ... | |
522+
| taint.cpp:462:6:462:11 | call to source | taint.cpp:462:2:462:13 | ... = ... | |
523+
| taint.cpp:462:6:462:11 | call to source | taint.cpp:465:7:465:7 | x | |
524+
| taint.cpp:462:6:462:11 | call to source | taint.cpp:468:7:468:7 | x | |
525+
| taint.cpp:462:6:462:11 | call to source | taint.cpp:470:7:470:7 | x | |
526+
| taint.cpp:463:6:463:6 | 0 | taint.cpp:463:2:463:6 | ... = ... | |
527+
| taint.cpp:463:6:463:6 | 0 | taint.cpp:466:7:466:7 | y | |
528+
| taint.cpp:463:6:463:6 | 0 | taint.cpp:468:10:468:10 | y | |
529+
| taint.cpp:463:6:463:6 | 0 | taint.cpp:471:7:471:7 | y | |
530+
| taint.cpp:468:7:468:7 | ref arg x | taint.cpp:470:7:470:7 | x | |
531+
| taint.cpp:468:10:468:10 | ref arg y | taint.cpp:471:7:471:7 | y | |

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void test_memcpy(int *source) {
195195
sink(x);
196196
}
197197

198-
// --- swap ---
198+
// --- std::swap ---
199199

200200
namespace std {
201201
template<class T> constexpr void swap(T& a, T& b);
@@ -446,3 +446,27 @@ void test_qualifiers()
446446
sink(d); // tainted
447447
sink(d.getString()); // tainted
448448
}
449+
450+
// --- non-standard swap ---
451+
452+
void swop(int &a, int &b)
453+
{
454+
int c = a;
455+
a = b;
456+
b = c;
457+
}
458+
459+
void test_swop() {
460+
int x, y;
461+
462+
x = source();
463+
y = 0;
464+
465+
sink(x); // tainted
466+
sink(y); // clean
467+
468+
swop(x, y);
469+
470+
sink(x); // clean [FALSE POSITIVE]
471+
sink(y); // tainted
472+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@
5858
| taint.cpp:439:10:439:18 | call to getMember | taint.cpp:437:15:437:20 | call to source |
5959
| taint.cpp:446:7:446:7 | d | taint.cpp:445:14:445:28 | call to source |
6060
| taint.cpp:447:9:447:17 | call to getString | taint.cpp:445:14:445:28 | call to source |
61+
| taint.cpp:465:7:465:7 | x | taint.cpp:462:6:462:11 | call to source |
62+
| taint.cpp:470:7:470:7 | x | taint.cpp:462:6:462:11 | call to source |
63+
| taint.cpp:471:7:471:7 | y | taint.cpp:462:6:462:11 | 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
@@ -42,3 +42,4 @@
4242
| taint.cpp:439:10:439:18 | taint.cpp:437:15:437:20 | AST only |
4343
| taint.cpp:446:7:446:7 | taint.cpp:445:14:445:28 | AST only |
4444
| taint.cpp:447:9:447:17 | taint.cpp:445:14:445:28 | AST only |
45+
| taint.cpp:471:7:471:7 | taint.cpp:462:6:462:11 | AST only |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@
2020
| taint.cpp:382:7:382:7 | a | taint.cpp:377:23:377:28 | source |
2121
| taint.cpp:429:7:429:7 | b | taint.cpp:428:13:428:18 | call to source |
2222
| taint.cpp:430:9:430:14 | member | taint.cpp:428:13:428:18 | call to source |
23+
| taint.cpp:465:7:465:7 | x | taint.cpp:462:6:462:11 | call to source |
24+
| taint.cpp:470:7:470:7 | x | taint.cpp:462:6:462:11 | call to source |

0 commit comments

Comments
 (0)