Skip to content

Commit ac6acfb

Browse files
committed
C++: Use data flow.
1 parent 11b8d41 commit ac6acfb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cpp/ql/lib/semmle/code/cpp/commons/NullTermination.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import cpp
22
private import semmle.code.cpp.models.interfaces.ArrayFunction
33
private import semmle.code.cpp.models.implementations.Strcat
4+
import semmle.code.cpp.dataflow.DataFlow
45

56
private predicate mayAddNullTerminatorHelper(Expr e, VariableAccess va, Expr e0) {
67
exists(StackVariable v0, Expr val |
@@ -64,10 +65,9 @@ predicate mayAddNullTerminator(Expr e, VariableAccess va) {
6465
// function containing assembler code
6566
exists(AsmStmt s | s.getEnclosingFunction() = f)
6667
or
67-
// function where the relevant parameter is returned (leaking it)
68-
exists(ReturnStmt rs |
69-
rs.getEnclosingFunction() = f and rs.getExpr().getAChild*() = f.getParameter(i).getAnAccess()
70-
)
68+
// function where the relevant parameter is returned (leaking it to be potentially null terminated elsewhere)
69+
DataFlow::localFlow(DataFlow::parameterNode(f.getParameter(i)),
70+
DataFlow::exprNode(any(ReturnStmt rs).getExpr()))
7171
)
7272
or
7373
// Call without target (e.g., function pointer call)

0 commit comments

Comments
 (0)