Skip to content

Commit 9807c0b

Browse files
committed
C++: Filter type-based reasons out of MCTV queries.
1 parent b14db86 commit 9807c0b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ private Instruction getABoundIn(SemBound b, IRFunction func) {
2020
pragma[inline]
2121
private predicate boundedImpl(Instruction i, Instruction b, int delta) {
2222
exists(SemBound bound, IRFunction func |
23-
semBounded(getSemanticExpr(i), bound, delta, true, _) and
23+
semBounded(getSemanticExpr(i), bound, delta, true,
24+
any(SemReason reason | not reason instanceof SemTypeReason)) and
2425
b = getABoundIn(bound, func) and
2526
i.getEnclosingIRFunction() = func
2627
)

cpp/ql/src/experimental/Security/CWE/CWE-193/ConstantSizeArrayOffByOne.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Instruction getABoundIn(SemBound b, IRFunction func) {
2828
pragma[inline]
2929
predicate boundedImpl(Instruction i, Instruction b, int delta) {
3030
exists(SemBound bound, IRFunction func |
31-
semBounded(getSemanticExpr(i), bound, delta, true, _) and
31+
semBounded(getSemanticExpr(i), bound, delta, true,
32+
any(SemReason reason | not reason instanceof SemTypeReason)) and
3233
b = getABoundIn(bound, func) and
3334
pragma[only_bind_out](i.getEnclosingIRFunction()) = func
3435
)
@@ -93,7 +94,8 @@ predicate arrayTypeHasSizes(ArrayType arr, int baseTypeSize, int size) {
9394
bindingset[pai]
9495
pragma[inline_late]
9596
predicate constantUpperBounded(PointerArithmeticInstruction pai, int delta) {
96-
semBounded(getSemanticExpr(pai.getRight()), any(SemZeroBound b), delta, true, _)
97+
semBounded(getSemanticExpr(pai.getRight()), any(SemZeroBound b), delta, true,
98+
any(SemReason reason | not reason instanceof SemTypeReason))
9799
}
98100

99101
bindingset[pai, size]

0 commit comments

Comments
 (0)