Skip to content

Commit 972d008

Browse files
committed
C++: Generalize std::move data flow
1 parent 8018346 commit 972d008

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowUtil.qll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,14 @@ private predicate exprToExprStep_nocfg(Expr fromExpr, Expr toExpr) {
292292
fromExpr = op.getOperand()
293293
)
294294
or
295-
toExpr = any(FunctionCall moveCall |
296-
moveCall.getTarget().getNamespace().getName() = "std" and
297-
moveCall.getTarget().getName() = "move" and
298-
fromExpr = moveCall.getArgument(0)
295+
toExpr = any(Call call |
296+
exists(DataFlowFunction f, FunctionInput inModel , FunctionOutput outModel, int iIn |
297+
call.getTarget() = f and
298+
f.hasDataFlow(inModel, outModel) and
299+
outModel.isOutReturnValue() and
300+
inModel.isInParameter(iIn) and
301+
fromExpr = call.getArgument(iIn)
302+
)
299303
)
300304
}
301305

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@
3131
| test.cpp:24:10:24:11 | t2 | test.cpp:26:8:26:9 | t1 |
3232
| test.cpp:430:48:430:54 | source1 | test.cpp:432:17:432:23 | source1 |
3333
| test.cpp:431:12:431:13 | 0 | test.cpp:432:11:432:13 | tmp |
34+
| test.cpp:432:10:432:13 | & ... | test.cpp:432:3:432:8 | call to memcpy |
3435
| test.cpp:432:10:432:13 | ref arg & ... | test.cpp:433:8:433:10 | tmp |
3536
| test.cpp:432:17:432:23 | source1 | test.cpp:432:10:432:13 | ref arg & ... |
3637
| test.cpp:436:53:436:59 | source1 | test.cpp:439:17:439:23 | source1 |
3738
| test.cpp:436:66:436:66 | b | test.cpp:441:7:441:7 | b |
3839
| test.cpp:437:12:437:13 | 0 | test.cpp:438:19:438:21 | tmp |
3940
| test.cpp:437:12:437:13 | 0 | test.cpp:439:11:439:13 | tmp |
41+
| test.cpp:439:10:439:13 | & ... | test.cpp:439:3:439:8 | call to memcpy |
4042
| test.cpp:439:10:439:13 | ref arg & ... | test.cpp:439:33:439:35 | tmp |
4143
| test.cpp:439:10:439:13 | ref arg & ... | test.cpp:440:8:440:10 | tmp |
4244
| test.cpp:439:10:439:13 | ref arg & ... | test.cpp:442:10:442:12 | tmp |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@
129129
| taint.cpp:164:19:164:24 | call to source | taint.cpp:172:18:172:24 | tainted | |
130130
| taint.cpp:165:22:165:25 | {...} | taint.cpp:170:10:170:15 | buffer | |
131131
| taint.cpp:165:24:165:24 | 0 | taint.cpp:165:22:165:25 | {...} | TAINT |
132+
| taint.cpp:170:10:170:15 | buffer | taint.cpp:170:3:170:8 | call to strcpy | |
132133
| taint.cpp:170:10:170:15 | ref arg buffer | taint.cpp:171:8:171:13 | buffer | |
133134
| taint.cpp:171:8:171:13 | ref arg buffer | taint.cpp:172:10:172:15 | buffer | |
135+
| taint.cpp:172:10:172:15 | buffer | taint.cpp:172:3:172:8 | call to strcat | |
134136
| taint.cpp:172:10:172:15 | ref arg buffer | taint.cpp:173:8:173:13 | buffer | |
135137
| taint.cpp:180:19:180:19 | p | taint.cpp:181:9:181:9 | p | |
136138
| taint.cpp:181:9:181:9 | p | taint.cpp:181:8:181:9 | * ... | TAINT |

0 commit comments

Comments
 (0)