@@ -19,7 +19,7 @@ import semmle.code.cpp.ir.dataflow.TaintTracking
19
19
import semmle.code.cpp.ir.IR
20
20
import semmle.code.cpp.controlflow.IRGuards
21
21
import semmle.code.cpp.security.FlowSources
22
- import DataFlow :: PathGraph
22
+ import TaintedAllocationSize :: PathGraph
23
23
24
24
/**
25
25
* Holds if `alloc` is an allocation, and `tainted` is a child of it that is a
@@ -54,14 +54,12 @@ predicate nodeIsBarrierEqualityCandidate(DataFlow::Node node, Operand access, Va
54
54
55
55
predicate isFlowSource ( FlowSource source , string sourceType ) { sourceType = source .getSourceType ( ) }
56
56
57
- class TaintedAllocationSizeConfiguration extends TaintTracking :: Configuration {
58
- TaintedAllocationSizeConfiguration ( ) { this = "TaintedAllocationSizeConfiguration" }
57
+ module TaintedAllocationSizeConfiguration implements DataFlow :: ConfigSig {
58
+ predicate isSource ( DataFlow :: Node source ) { isFlowSource ( source , _ ) }
59
59
60
- override predicate isSource ( DataFlow:: Node source ) { isFlowSource ( source , _ ) }
60
+ predicate isSink ( DataFlow:: Node sink ) { allocSink ( _ , sink ) }
61
61
62
- override predicate isSink ( DataFlow:: Node sink ) { allocSink ( _, sink ) }
63
-
64
- override predicate isSanitizer ( DataFlow:: Node node ) {
62
+ predicate isBarrier ( DataFlow:: Node node ) {
65
63
exists ( Expr e | e = node .asExpr ( ) |
66
64
// There can be two separate reasons for `convertedExprMightOverflow` not holding:
67
65
// 1. `e` really cannot overflow.
@@ -97,12 +95,14 @@ class TaintedAllocationSizeConfiguration extends TaintTracking::Configuration {
97
95
}
98
96
}
99
97
98
+ module TaintedAllocationSize = TaintTracking:: Make< TaintedAllocationSizeConfiguration > ;
99
+
100
100
from
101
- Expr alloc , DataFlow :: PathNode source , DataFlow :: PathNode sink , string taintCause ,
102
- TaintedAllocationSizeConfiguration conf
101
+ Expr alloc , TaintedAllocationSize :: PathNode source , TaintedAllocationSize :: PathNode sink ,
102
+ string taintCause
103
103
where
104
104
isFlowSource ( source .getNode ( ) , taintCause ) and
105
- conf . hasFlowPath ( source , sink ) and
105
+ TaintedAllocationSize :: hasFlowPath ( source , sink ) and
106
106
allocSink ( alloc , sink .getNode ( ) )
107
107
select alloc , source , sink , "This allocation size is derived from $@ and might overflow." ,
108
108
source .getNode ( ) , "user input (" + taintCause + ")"
0 commit comments