Skip to content

Commit 1867d58

Browse files
committed
CPP: Allow flow to return value.
1 parent 704bfe7 commit 1867d58

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ private predicate exprToExprStep(Expr exprIn, Expr exprOut) {
140140
(
141141
exprOut = call and
142142
outModel.isReturnValueDeref()
143+
or
144+
exprOut = call and
145+
outModel.isReturnValue()
143146
) and
144147
f.hasTaintFlow(inModel, outModel) and
145148
(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void test_qualifiers()
421421
sink(a.getMember());
422422
a.setMember(source());
423423
sink(a); // tainted
424-
sink(a.getMember()); // tainted [NOT DETECTED]
424+
sink(a.getMember()); // tainted
425425

426426
sink(b);
427427
sink(b.getMember());
@@ -436,7 +436,7 @@ void test_qualifiers()
436436
sink(c->getMember());
437437
c->setMember(source());
438438
sink(c); // tainted (deref)
439-
sink(c->getMember()); // tainted [NOT DETECTED]
439+
sink(c->getMember()); // tainted
440440

441441
delete c;
442442

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
| taint.cpp:372:7:372:7 | a | taint.cpp:365:24:365:29 | source |
4141
| taint.cpp:391:7:391:7 | a | taint.cpp:385:27:385:32 | source |
4242
| taint.cpp:423:7:423:7 | a | taint.cpp:422:14:422:19 | call to source |
43+
| taint.cpp:424:9:424:17 | call to getMember | taint.cpp:422:14:422:19 | call to source |
4344
| taint.cpp:430:9:430:14 | member | taint.cpp:428:13:428:18 | call to source |
4445
| taint.cpp:438:7:438:7 | c | taint.cpp:437:15:437:20 | call to source |
46+
| taint.cpp:439:10:439:18 | call to getMember | taint.cpp:437:15:437:20 | call to source |
4547
| taint.cpp:446:7:446:7 | d | taint.cpp:445:14:445:28 | call to source |
4648
| taint.cpp:447:9:447:17 | call to getString | taint.cpp:445:14:445:28 | call to source |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
| taint.cpp:372:7:372:7 | taint.cpp:365:24:365:29 | AST only |
2828
| taint.cpp:391:7:391:7 | taint.cpp:385:27:385:32 | AST only |
2929
| taint.cpp:423:7:423:7 | taint.cpp:422:14:422:19 | AST only |
30+
| taint.cpp:424:9:424:17 | taint.cpp:422:14:422:19 | AST only |
3031
| taint.cpp:429:7:429:7 | taint.cpp:428:13:428:18 | IR only |
3132
| taint.cpp:430:9:430:14 | taint.cpp:428:13:428:18 | AST only |
3233
| taint.cpp:438:7:438:7 | taint.cpp:437:15:437:20 | AST only |
34+
| taint.cpp:439:10:439:18 | taint.cpp:437:15:437:20 | AST only |
3335
| taint.cpp:446:7:446:7 | taint.cpp:445:14:445:28 | AST only |
3436
| taint.cpp:447:9:447:17 | taint.cpp:445:14:445:28 | AST only |

0 commit comments

Comments
 (0)