Skip to content

Commit 6fa9533

Browse files
committed
C++: Revert the changes to default taint tracking and TaintedAllocationSize.ql
1 parent 20ce4cd commit 6fa9533

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DefaultTaintTrackingImpl.qll

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,16 @@ private predicate hasUpperBoundsCheck(Variable var) {
168168
private predicate nodeIsBarrierEqualityCandidate(
169169
DataFlow::Node node, Operand access, Variable checkedVar
170170
) {
171-
exists(Instruction instr | instr = node.asOperand().getDef() |
172-
readsVariable(instr, checkedVar) and
173-
any(IRGuardCondition guard).ensuresEq(access, _, _, instr.getBlock(), true)
174-
)
171+
readsVariable(node.asInstruction(), checkedVar) and
172+
any(IRGuardCondition guard).ensuresEq(access, _, _, node.asInstruction().getBlock(), true)
175173
}
176174

177175
cached
178176
private module Cached {
179177
cached
180178
predicate nodeIsBarrier(DataFlow::Node node) {
181-
exists(Variable checkedVar, Instruction instr | instr = node.asOperand().getDef() |
182-
readsVariable(instr, checkedVar) and
179+
exists(Variable checkedVar |
180+
readsVariable(node.asInstruction(), checkedVar) and
183181
hasUpperBoundsCheck(checkedVar)
184182
)
185183
or

cpp/ql/src/Security/CWE/CWE-190/TaintedAllocationSize.ql

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ predicate hasUpperBoundsCheck(Variable var) {
4646
}
4747

4848
predicate nodeIsBarrierEqualityCandidate(DataFlow::Node node, Operand access, Variable checkedVar) {
49-
exists(Instruction instr | instr = node.asOperand().getDef() |
50-
readsVariable(instr, checkedVar) and
51-
any(IRGuardCondition guard).ensuresEq(access, _, _, instr.getBlock(), true)
52-
)
49+
readsVariable(node.asInstruction(), checkedVar) and
50+
any(IRGuardCondition guard).ensuresEq(access, _, _, node.asInstruction().getBlock(), true)
5351
}
5452

5553
predicate isFlowSource(FlowSource source, string sourceType) { sourceType = source.getSourceType() }
@@ -81,8 +79,8 @@ class TaintedAllocationSizeConfiguration extends TaintTracking::Configuration {
8179
e = any(PointerDiffExpr diff).getAnOperand()
8280
)
8381
or
84-
exists(Variable checkedVar, Instruction instr | instr = node.asOperand().getDef() |
85-
readsVariable(instr, checkedVar) and
82+
exists(Variable checkedVar |
83+
readsVariable(node.asInstruction(), checkedVar) and
8684
hasUpperBoundsCheck(checkedVar)
8785
)
8886
or

0 commit comments

Comments
 (0)