Skip to content

Commit 64d7b49

Browse files
committed
C++: Prune flow states based on 'PointerArithmeticToDerefConfig'.
1 parent 4ed7450 commit 64d7b49

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

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

81-
predicate pointerArithOverflow(
81+
predicate pointerArithOverflow0(
8282
PointerArithmeticInstruction pai, Field f, int size, int bound, int delta
8383
) {
8484
pai.getElementSize() = f.getUnspecifiedType().(ArrayType).getBaseType().getSize() and
@@ -89,14 +89,21 @@ predicate pointerArithOverflow(
8989

9090
module PointerArithmeticToDerefConfig implements DataFlow::ConfigSig {
9191
predicate isSource(DataFlow::Node source) {
92-
pointerArithOverflow(source.asInstruction(), _, _, _, _)
92+
pointerArithOverflow0(source.asInstruction(), _, _, _, _)
9393
}
9494

9595
predicate isSink(DataFlow::Node sink) { isInvalidPointerDerefSink1(sink, _, _) }
9696
}
9797

9898
module PointerArithmeticToDerefFlow = DataFlow::Global<PointerArithmeticToDerefConfig>;
9999

100+
predicate pointerArithOverflow(
101+
PointerArithmeticInstruction pai, Field f, int size, int bound, int delta
102+
) {
103+
pointerArithOverflow0(pai, f, size, bound, delta) and
104+
PointerArithmeticToDerefFlow::flow(DataFlow::instructionNode(pai), _)
105+
}
106+
100107
module FieldAddressToDerefConfig implements DataFlow::StateConfigSig {
101108
newtype FlowState =
102109
additional TArray(Field f) { pointerArithOverflow(_, f, _, _, _) } or

0 commit comments

Comments
 (0)