Skip to content

Commit b275987

Browse files
authored
Merge pull request github#3219 from jbj/DefaultTaintTracking-partial-no-structs
C++: Avoid partial chi flow to struct/class
2 parents fa6705a + 39911af commit b275987

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,22 @@ private predicate instructionTaintStep(Instruction i1, Instruction i2) {
201201
or
202202
i2.(UnaryInstruction).getUnary() = i1
203203
or
204-
i2.(ChiInstruction).getPartial() = i1 and
204+
// Flow out of definition-by-reference
205+
i2.(ChiInstruction).getPartial() = i1.(WriteSideEffectInstruction) and
205206
not i2.isResultConflated()
206207
or
208+
// Flow from an element to an array or union that contains it.
209+
i2.(ChiInstruction).getPartial() = i1 and
210+
not i2.isResultConflated() and
211+
exists(Type t | i2.getResultLanguageType().hasType(t, false) |
212+
t instanceof Union
213+
or
214+
t instanceof ArrayType
215+
or
216+
// Buffers or unknown size
217+
t instanceof UnknownType
218+
)
219+
or
207220
exists(BinaryInstruction bin |
208221
bin = i2 and
209222
predictableInstruction(i2.getAnOperand().getDef()) and

0 commit comments

Comments
 (0)