@@ -77,6 +77,15 @@ predicate hasSize(HeuristicAllocationExpr alloc, DataFlow::Node n, int state) {
7777 )
7878}
7979
80+ /**
81+ * Gets the virtual dispatch branching limit when calculating field flow while searching
82+ * for flow from an allocation to the construction of an out-of-bounds pointer.
83+ *
84+ * This can be overridden to a smaller value to improve performance (a
85+ * value of 0 disables field flow), or a larger value to get more results.
86+ */
87+ int allocationToInvalidPointerFieldFlowBranchLimit ( ) { result = 0 }
88+
8089/**
8190 * A module that encapsulates a barrier guard to remove false positives from flow like:
8291 * ```cpp
@@ -105,6 +114,8 @@ private module SizeBarrier {
105114 InterestingPointerAddInstruction:: isInterestingSize ( source )
106115 }
107116
117+ int fieldFlowBranchLimit ( ) { result = allocationToInvalidPointerFieldFlowBranchLimit ( ) }
118+
108119 /**
109120 * Holds if `small <= large + k` holds if `g` evaluates to `testIsTrue`.
110121 */
@@ -202,6 +213,8 @@ private module InterestingPointerAddInstruction {
202213 hasSize ( source .asConvertedExpr ( ) , _, _)
203214 }
204215
216+ int fieldFlowBranchLimit ( ) { result = allocationToInvalidPointerFieldFlowBranchLimit ( ) }
217+
205218 predicate isSink ( DataFlow:: Node sink ) {
206219 sink .asInstruction ( ) = any ( PointerAddInstruction pai ) .getLeft ( )
207220 }
@@ -258,6 +271,10 @@ private module Config implements ProductFlow::StateConfigSig {
258271 hasSize ( allocSource .asConvertedExpr ( ) , sizeSource , sizeAddend )
259272 }
260273
274+ int fieldFlowBranchLimit1 ( ) { result = allocationToInvalidPointerFieldFlowBranchLimit ( ) }
275+
276+ int fieldFlowBranchLimit2 ( ) { result = allocationToInvalidPointerFieldFlowBranchLimit ( ) }
277+
261278 predicate isSinkPair (
262279 DataFlow:: Node allocSink , FlowState1 unit , DataFlow:: Node sizeSink , FlowState2 sizeAddend
263280 ) {
0 commit comments