@@ -19,7 +19,7 @@ import semmle.code.cpp.ir.dataflow.TaintTracking
1919import semmle.code.cpp.ir.IR
2020import semmle.code.cpp.controlflow.IRGuards
2121import semmle.code.cpp.security.FlowSources
22- import DataFlow :: PathGraph
22+ import TaintedAllocationSize :: PathGraph
2323
2424/**
2525 * 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
5454
5555predicate isFlowSource ( FlowSource source , string sourceType ) { sourceType = source .getSourceType ( ) }
5656
57- class TaintedAllocationSizeConfiguration extends TaintTracking :: Configuration {
58- TaintedAllocationSizeConfiguration ( ) { this = "TaintedAllocationSizeConfiguration" }
57+ module TaintedAllocationSizeConfiguration implements DataFlow :: ConfigSig {
58+ predicate isSource ( DataFlow :: Node source ) { isFlowSource ( source , _ ) }
5959
60- override predicate isSource ( DataFlow:: Node source ) { isFlowSource ( source , _ ) }
60+ predicate isSink ( DataFlow:: Node sink ) { allocSink ( _ , sink ) }
6161
62- override predicate isSink ( DataFlow:: Node sink ) { allocSink ( _, sink ) }
63-
64- override predicate isSanitizer ( DataFlow:: Node node ) {
62+ predicate isBarrier ( DataFlow:: Node node ) {
6563 exists ( Expr e | e = node .asExpr ( ) |
6664 // There can be two separate reasons for `convertedExprMightOverflow` not holding:
6765 // 1. `e` really cannot overflow.
@@ -97,12 +95,14 @@ class TaintedAllocationSizeConfiguration extends TaintTracking::Configuration {
9795 }
9896}
9997
98+ module TaintedAllocationSize = TaintTracking:: Make< TaintedAllocationSizeConfiguration > ;
99+
100100from
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
103103where
104104 isFlowSource ( source .getNode ( ) , taintCause ) and
105- conf . hasFlowPath ( source , sink ) and
105+ TaintedAllocationSize :: hasFlowPath ( source , sink ) and
106106 allocSink ( alloc , sink .getNode ( ) )
107107select alloc , source , sink , "This allocation size is derived from $@ and might overflow." ,
108108 source .getNode ( ) , "user input (" + taintCause + ")"
0 commit comments