@@ -3,17 +3,8 @@ private import semmle.code.cpp.models.interfaces.ArrayFunction
3
3
private import semmle.code.cpp.models.implementations.Strcat
4
4
import semmle.code.cpp.dataflow.DataFlow
5
5
6
- private predicate mayAddNullTerminatorHelper ( Expr e , VariableAccess va , Expr e0 ) {
7
- exists ( StackVariable v0 , Expr val |
8
- exprDefinition ( v0 , e , val ) and
9
- val .getAChild * ( ) = va and
10
- mayAddNullTerminator ( e0 , v0 .getAnAccess ( ) )
11
- )
12
- }
13
-
14
6
/**
15
- * Holds if the expression `e` may add a null terminator to the string in
16
- * variable `v`.
7
+ * Holds if the expression `e` may add a null terminator to the string in `va`.
17
8
*/
18
9
predicate mayAddNullTerminator ( Expr e , VariableAccess va ) {
19
10
// Assignment: dereferencing or array access
@@ -30,14 +21,12 @@ predicate mayAddNullTerminator(Expr e, VariableAccess va) {
30
21
)
31
22
or
32
23
// Assignment to another stack variable
33
- exists ( Expr e0 , BasicBlock bb , int pos , BasicBlock bb0 , int pos0 |
34
- mayAddNullTerminatorHelper ( e , va , e0 ) and
35
- bb .getNode ( pos ) = e and
36
- bb0 .getNode ( pos0 ) = e0
37
- |
38
- bb = bb0 and pos < pos0
39
- or
40
- bb .getASuccessor + ( ) = bb0
24
+ exists ( Expr e0 |
25
+ exists ( StackVariable v0 , Expr val |
26
+ exprDefinition ( v0 , e , val ) and // e resembles `v0 := val`
27
+ val .getAChild * ( ) = va and
28
+ mayAddNullTerminator ( e0 , v0 .getAnAccess ( ) )
29
+ )
41
30
)
42
31
or
43
32
// Assignment to non-stack variable
0 commit comments