Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowUtil.qll
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ private predicate exprToExprStep_nocfg(Expr fromExpr, Expr toExpr) {
fromExpr = op.getOperand()
)
or
toExpr = any(StmtExpr stmtExpr |
fromExpr = stmtExpr.getResultExpr()
)
or
toExpr = any(Call call |
exists(DataFlowFunction f, FunctionInput inModel , FunctionOutput outModel, int iIn |
call.getTarget() = f and
Expand Down
17 changes: 17 additions & 0 deletions cpp/ql/test/library-tests/dataflow/dataflow-tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,20 @@ void intArraySourceCaller2() {
sink(local); // tainted
sink(*local); // clean
}

///////////////////////////////////////////////////////////////////////////////

void throughStmtExpr(int source1, int clean1) {
sink( ({ source1; }) ); // tainted
sink( ({ clean1; }) ); // clean

int local = ({
int tmp;
if (clean1)
tmp = source1;
else
tmp = clean1;
tmp;
});
sink(local); // tainted
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
| test.cpp:478:8:478:12 | local | test.cpp:477:20:477:24 | ref arg local |
| test.cpp:485:8:485:12 | local | test.cpp:484:18:484:23 | ref arg & ... |
| test.cpp:491:8:491:12 | local | test.cpp:490:18:490:22 | ref arg local |
| test.cpp:498:9:498:22 | (statement expression) | test.cpp:497:26:497:32 | source1 |
| test.cpp:509:8:509:12 | local | test.cpp:497:26:497:32 | source1 |
| true_upon_entry.cpp:21:8:21:8 | x | true_upon_entry.cpp:17:11:17:16 | call to source |
| true_upon_entry.cpp:29:8:29:8 | x | true_upon_entry.cpp:27:9:27:14 | call to source |
| true_upon_entry.cpp:39:8:39:8 | x | true_upon_entry.cpp:33:11:33:16 | call to source |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
| test.cpp:477:20:477:24 | test.cpp:478:8:478:12 | AST only |
| test.cpp:484:18:484:23 | test.cpp:485:8:485:12 | AST only |
| test.cpp:490:18:490:22 | test.cpp:491:8:491:12 | AST only |
| test.cpp:497:26:497:32 | test.cpp:498:9:498:22 | AST only |
| test.cpp:497:26:497:32 | test.cpp:509:8:509:12 | AST only |
| true_upon_entry.cpp:9:11:9:16 | true_upon_entry.cpp:13:8:13:8 | IR only |
| true_upon_entry.cpp:62:11:62:16 | true_upon_entry.cpp:66:8:66:8 | IR only |
| true_upon_entry.cpp:98:11:98:16 | true_upon_entry.cpp:105:8:105:8 | IR only |