File tree Expand file tree Collapse file tree 6 files changed +29
-1
lines changed
src/semmle/code/cpp/models
test/library-tests/dataflow/taint-tests Expand file tree Collapse file tree 6 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ private import implementations.Pure
66private import implementations.Strcat
77private import implementations.Strcpy
88private import implementations.Strftime
9+ private import implementations.Swap
Original file line number Diff line number Diff line change 1+ import semmle.code.cpp.models.interfaces.DataFlow
2+ import semmle.code.cpp.models.interfaces.Taint
3+
4+ /**
5+ * The standard function `swap`.
6+ */
7+ class Swap extends DataFlowFunction {
8+ Swap ( ) {
9+ this .hasQualifiedName ( "std" , "swap" )
10+ }
11+
12+ override predicate hasDataFlow ( FunctionInput input , FunctionOutput output ) {
13+ (
14+ input .isInParameterPointer ( 0 ) and
15+ output .isOutParameterPointer ( 1 )
16+ )
17+ or
18+ (
19+ input .isInParameterPointer ( 1 ) and
20+ output .isOutParameterPointer ( 0 )
21+ )
22+ }
23+ }
Original file line number Diff line number Diff line change 171171| taint.cpp:208:6:208:6 | 0 | taint.cpp:216:7:216:7 | y | |
172172| taint.cpp:213:12:213:12 | ref arg x | taint.cpp:213:12:213:12 | x | |
173173| taint.cpp:213:12:213:12 | ref arg x | taint.cpp:215:7:215:7 | x | |
174+ | taint.cpp:213:12:213:12 | x | taint.cpp:213:15:213:15 | ref arg y | |
174175| taint.cpp:213:15:213:15 | ref arg y | taint.cpp:213:15:213:15 | y | |
175176| taint.cpp:213:15:213:15 | ref arg y | taint.cpp:216:7:216:7 | y | |
177+ | taint.cpp:213:15:213:15 | y | taint.cpp:213:12:213:12 | ref arg x | |
Original file line number Diff line number Diff line change @@ -213,5 +213,5 @@ void test_swap() {
213213 std::swap (x, y);
214214
215215 sink (x); // [FALSE POSITIVE]
216- sink (y); // tainted [NOT DETECTED]
216+ sink (y); // tainted
217217}
Original file line number Diff line number Diff line change 1616| taint.cpp:195:7:195:7 | x | taint.cpp:193:6:193:6 | x |
1717| taint.cpp:210:7:210:7 | x | taint.cpp:207:6:207:11 | call to source |
1818| taint.cpp:215:7:215:7 | x | taint.cpp:207:6:207:11 | call to source |
19+ | taint.cpp:216:7:216:7 | y | taint.cpp:207:6:207:11 | call to source |
Original file line number Diff line number Diff line change 88| taint.cpp:192:23:192:28 | taint.cpp:195:7:195:7 | AST only |
99| taint.cpp:193:6:193:6 | taint.cpp:195:7:195:7 | AST only |
1010| taint.cpp:207:6:207:11 | taint.cpp:215:7:215:7 | AST only |
11+ | taint.cpp:207:6:207:11 | taint.cpp:216:7:216:7 | AST only |
You can’t perform that action at this time.
0 commit comments