Skip to content

Commit c8edf31

Browse files
committed
C++: Remove the use of range analysis in 'invalidPointerToDerefSource'.
1 parent e2ef0dc commit c8edf31

File tree

3 files changed

+26
-138
lines changed

3 files changed

+26
-138
lines changed

cpp/ql/lib/semmle/code/cpp/security/InvalidPointerDereference/InvalidPointerToDereference.qll

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,7 @@ private import DataFlow::GlobalWithState<InvalidPointerToDerefConfig>
198198

199199
/**
200200
* Holds if `allocSource` is dataflow node that represents an allocation that flows to the
201-
* left-hand side of the pointer-arithmetic `pai`, and `derefSource <= pai + derefSourcePaiDelta`.
202-
*
203-
* For example, if `pai` is a pointer-arithmetic operation `p + size` in an expression such
204-
* as `(p + size) + 1` and `derefSource` is the node representing `(p + size) + 1`. In this
205-
* case `derefSourcePaiDelta` is 1.
201+
* left-hand side of the pointer-arithmetic instruction represented by `derefSource`.
206202
*/
207203
private predicate invalidPointerToDerefSource(
208204
DataFlow::Node allocSource, PointerArithmeticInstruction pai, DataFlow::Node derefSource,
@@ -213,9 +209,8 @@ private predicate invalidPointerToDerefSource(
213209
// `deltaDerefSourceAndPai` is the constant difference between the pointer-arithmetic instruction
214210
// and the instruction computing the address for which we will search for a dereference.
215211
AllocToInvalidPointer::pointerAddInstructionHasBounds(allocSource, pai, _, _) and
216-
// derefSource <= pai + deltaDerefSourceAndPai
217-
bounded2(derefSource.asInstruction(), pai, deltaDerefSourceAndPai) and
218-
deltaDerefSourceAndPai >= 0
212+
derefSource.asInstruction() = pai and
213+
deltaDerefSourceAndPai = 0
219214
}
220215

221216
/**

0 commit comments

Comments
 (0)