Skip to content

Commit 4778914

Browse files
committed
CPP: Repair flow.
1 parent d9f6895 commit 4778914

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ private predicate exprToExprStep(Expr exprIn, Expr exprOut) {
132132
// dest_ptr = strdup(tainted_ptr)
133133
inModel.isParameterDeref(argInIndex) and
134134
exprIn = call.getArgument(argInIndex)
135+
or
136+
inModel.isParameter(argInIndex) and
137+
exprIn = call.getArgument(argInIndex)
135138
)
136139
)
137140
or
@@ -173,6 +176,9 @@ private predicate exprToDefinitionByReferenceStep(Expr exprIn, Expr argOut) {
173176
// memcpy(&dest_var, tainted_ptr, len)
174177
inModel.isParameterDeref(argInIndex) and
175178
exprIn = call.getArgument(argInIndex)
179+
or
180+
inModel.isParameter(argInIndex) and
181+
exprIn = call.getArgument(argInIndex)
176182
)
177183
)
178184
or

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,12 @@
338338
| taint.cpp:371:6:371:12 | call to strndup | taint.cpp:371:2:371:25 | ... = ... | |
339339
| taint.cpp:371:6:371:12 | call to strndup | taint.cpp:374:7:374:7 | c | |
340340
| taint.cpp:371:14:371:19 | source | taint.cpp:371:6:371:12 | call to strndup | TAINT |
341+
| taint.cpp:371:22:371:24 | 100 | taint.cpp:371:6:371:12 | call to strndup | TAINT |
341342
| taint.cpp:377:23:377:28 | source | taint.cpp:381:30:381:35 | source | |
342343
| taint.cpp:381:6:381:12 | call to strndup | taint.cpp:381:2:381:36 | ... = ... | |
343344
| taint.cpp:381:6:381:12 | call to strndup | taint.cpp:382:7:382:7 | a | |
344345
| taint.cpp:381:14:381:27 | hello, world | taint.cpp:381:6:381:12 | call to strndup | TAINT |
346+
| taint.cpp:381:30:381:35 | source | taint.cpp:381:6:381:12 | call to strndup | TAINT |
345347
| taint.cpp:385:27:385:32 | source | taint.cpp:389:13:389:18 | source | |
346348
| taint.cpp:389:6:389:11 | call to wcsdup | taint.cpp:389:2:389:19 | ... = ... | |
347349
| taint.cpp:389:6:389:11 | call to wcsdup | taint.cpp:391:7:391:7 | a | |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
| taint.cpp:352:7:352:7 | b | taint.cpp:330:6:330:11 | call to source |
4040
| taint.cpp:372:7:372:7 | a | taint.cpp:365:24:365:29 | source |
4141
| taint.cpp:374:7:374:7 | c | taint.cpp:365:24:365:29 | source |
42+
| taint.cpp:382:7:382:7 | a | taint.cpp:377:23:377:28 | source |
4243
| taint.cpp:391:7:391:7 | a | taint.cpp:385:27:385:32 | source |
4344
| taint.cpp:423:7:423:7 | a | taint.cpp:422:14:422:19 | call to source |
4445
| taint.cpp:424:9:424:17 | call to getMember | taint.cpp:422:14:422:19 | call to source |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
| taint.cpp:352:7:352:7 | taint.cpp:330:6:330:11 | AST only |
2727
| taint.cpp:372:7:372:7 | taint.cpp:365:24:365:29 | AST only |
2828
| taint.cpp:374:7:374:7 | taint.cpp:365:24:365:29 | AST only |
29+
| taint.cpp:382:7:382:7 | taint.cpp:377:23:377:28 | AST only |
2930
| taint.cpp:391:7:391:7 | taint.cpp:385:27:385:32 | AST only |
3031
| taint.cpp:423:7:423:7 | taint.cpp:422:14:422:19 | AST only |
3132
| taint.cpp:424:9:424:17 | taint.cpp:422:14:422:19 | AST only |

0 commit comments

Comments
 (0)