Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ce8612

Browse files
committed
C++ IR: allow inexact defs in taint tracking
1 parent 984405b commit 2ce8612

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ module TaintTracking {
145145
nodeTo instanceof PointerArithmeticInstruction
146146
or
147147
nodeTo instanceof FieldAddressInstruction
148+
or
149+
// The `CopyInstruction` case is also present in non-taint data flow, but
150+
// that uses `getDef` rather than `getAnyDef`. For taint, we want flow
151+
// from a definition of `myStruct` to a `myStruct.myField` expression.
152+
nodeTo instanceof CopyInstruction
148153
)
149154
or
150155
nodeTo.(LoadInstruction).getSourceAddress() = nodeFrom

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ UninitializedNode uninitializedNode(LocalVariable v) { result.getLocalVariable()
143143
*/
144144
predicate localFlowStep(Node nodeFrom, Node nodeTo) {
145145
nodeTo.(CopyInstruction).getSourceValue() = nodeFrom or
146-
nodeTo.(PhiInstruction).getAnOperand().getAnyDef() = nodeFrom or
146+
nodeTo.(PhiInstruction).getAnOperand().getDef() = nodeFrom or
147147
// Treat all conversions as flow, even conversions between different numeric types.
148148
nodeTo.(ConvertInstruction).getUnary() = nodeFrom
149149
}

0 commit comments

Comments
 (0)