Skip to content

Commit 0f08642

Browse files
committed
C++: Fix join in 'pointerArithOverflow0'.
1 parent 5bc844c commit 0f08642

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,16 @@ predicate isInvalidPointerDerefSink2(DataFlow::Node sink, Instruction i, string
7878
)
7979
}
8080

81+
pragma[nomagic]
82+
predicate arrayTypeHasSizes(ArrayType arr, int baseTypeSize, int arraySize) {
83+
arr.getBaseType().getSize() = baseTypeSize and
84+
arr.getArraySize() = arraySize
85+
}
86+
8187
predicate pointerArithOverflow0(
8288
PointerArithmeticInstruction pai, Field f, int size, int bound, int delta
8389
) {
84-
pai.getElementSize() = f.getUnspecifiedType().(ArrayType).getBaseType().getSize() and
85-
f.getUnspecifiedType().(ArrayType).getArraySize() = size and
90+
arrayTypeHasSizes(f.getUnspecifiedType(), pai.getElementSize(), size) and
8691
semBounded(getSemanticExpr(pai.getRight()), any(SemZeroBound b), bound, true, _) and
8792
delta = bound - size and
8893
delta >= 0 and

0 commit comments

Comments
 (0)