Skip to content

Commit 123e587

Browse files
committed
C++: Share RangeAnalysisUtil with 'cpp/overrun-write'.
1 parent 530c950 commit 123e587

File tree

4 files changed

+5
-23
lines changed

4 files changed

+5
-23
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* This file contains the range-analysis specific parts of the `cpp/invalid-pointer-deref` query
3-
* that is used by both `AllocationToInvalidPointer.qll` and `InvalidPointerToDereference.qll`.
2+
* This file contains the range-analysis specific parts of the `cpp/invalid-pointer-deref`
3+
* and `cpp/overrun-write` query.
44
*/
55

66
private import cpp

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private import semmle.code.cpp.ir.dataflow.internal.ProductFlow
5656
private import semmle.code.cpp.ir.ValueNumbering
5757
private import semmle.code.cpp.controlflow.IRGuards
5858
private import codeql.util.Unit
59-
private import RangeAnalysisUtil
59+
private import semmle.code.cpp.rangeanalysis.new.RangeAnalysisUtil
6060

6161
private VariableAccess getAVariableAccess(Expr e) { e.getAChild*() = result }
6262

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private import semmle.code.cpp.dataflow.new.DataFlow
8181
private import semmle.code.cpp.ir.ValueNumbering
8282
private import semmle.code.cpp.controlflow.IRGuards
8383
private import AllocationToInvalidPointer as AllocToInvalidPointer
84-
private import RangeAnalysisUtil
84+
private import semmle.code.cpp.rangeanalysis.new.RangeAnalysisUtil
8585

8686
private module InvalidPointerToDerefBarrier {
8787
private module BarrierConfig implements DataFlow::ConfigSig {

cpp/ql/src/Security/CWE/CWE-119/OverrunWriteProductFlow.ql

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,10 @@ import semmle.code.cpp.models.interfaces.Allocation
2020
import semmle.code.cpp.models.interfaces.ArrayFunction
2121
import semmle.code.cpp.rangeanalysis.new.internal.semantic.analysis.RangeAnalysis
2222
import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticExprSpecific
23+
import semmle.code.cpp.rangeanalysis.new.RangeAnalysisUtil
2324
import StringSizeFlow::PathGraph1
2425
import codeql.util.Unit
2526

26-
pragma[nomagic]
27-
Instruction getABoundIn(SemBound b, IRFunction func) {
28-
getSemanticExpr(result) = b.getExpr(0) and
29-
result.getEnclosingIRFunction() = func
30-
}
31-
32-
/**
33-
* Holds if `i <= b + delta`.
34-
*/
35-
bindingset[i]
36-
pragma[inline_late]
37-
predicate bounded(Instruction i, Instruction b, int delta) {
38-
exists(SemBound bound, IRFunction func |
39-
semBounded(getSemanticExpr(i), bound, delta, true, _) and
40-
b = getABoundIn(bound, func) and
41-
i.getEnclosingIRFunction() = func
42-
)
43-
}
44-
4527
VariableAccess getAVariableAccess(Expr e) { e.getAChild*() = result }
4628

4729
/**

0 commit comments

Comments
 (0)