Skip to content

Commit b09ff54

Browse files
committed
C++: restrict partial reads from chi nodes
1 parent 81a5238 commit b09ff54

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,16 @@ private predicate instructionTaintStep(Instruction i1, Instruction i2) {
189189
// Flow through pointer dereference
190190
i2.(LoadInstruction).getSourceAddress() = i1
191191
or
192-
i2.(LoadInstruction).getSourceValueOperand().getAnyDef() = i1
192+
// Flow through partial reads of arrays, unions, and pointer parameters
193+
// TODO: `UnknownType` includes *all* pointer parameters. We only want
194+
// array-like pointer parameters
195+
i2.(LoadInstruction).getSourceValueOperand().getAnyDef() = i1 and
196+
not i1.isResultConflated() and
197+
(
198+
i1.getResultType() instanceof ArrayType or
199+
i1.getResultType() instanceof UnknownType or
200+
i1.getResultType() instanceof Union
201+
)
193202
or
194203
i2.(UnaryInstruction).getUnary() = i1
195204
or

0 commit comments

Comments
 (0)