Skip to content

Commit b37c13d

Browse files
committed
C++: restore flow for non-class partial reads
This would otherwise have lost a good qltest result at CWE-134/semmle/funcs/funcsLocal.c:58:9:58:10
1 parent 9f40886 commit b37c13d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cpp/ql/src/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,17 @@ private predicate instructionTaintStep(Instruction i1, Instruction i2) {
199199
// Flow through pointer dereference
200200
i2.(LoadInstruction).getSourceAddress() = i1
201201
or
202+
// Flow through partial reads of arrays, unions, and pointer parameters
203+
// TODO: `UnknownType` includes *all* pointer parameters. We only want
204+
// array-like pointer parameters
205+
i2.(LoadInstruction).getSourceValueOperand().getAnyDef() = i1 and
206+
not i1.isResultConflated() and
207+
(
208+
i1.getResultType() instanceof ArrayType or
209+
i1.getResultType() instanceof UnknownType or
210+
i1.getResultType() instanceof Union
211+
)
212+
or
202213
// Unary instructions tend to preserve enough information in practice that we
203214
// want taint to flow through.
204215
// The exception is `FieldAddressInstruction`. Together with the rule for

0 commit comments

Comments
 (0)