@@ -105,6 +105,11 @@ class ArrayAllocation extends TArrayAllocation {
105105 result = this .asStackAllocation ( ) .getLocation ( ) or
106106 result = this .asDynamicAllocation ( ) .getLocation ( )
107107 }
108+
109+ DataFlow:: Node getNode ( ) {
110+ result .asExpr ( ) = this .asStackAllocation ( ) .getInitExpr ( ) or
111+ result .asConvertedExpr ( ) = this .asDynamicAllocation ( )
112+ }
108113}
109114
110115class PointerFormation extends TPointerFormation {
@@ -147,21 +152,16 @@ class PointerFormation extends TPointerFormation {
147152
148153module TrackArrayConfig implements DataFlow:: ConfigSig {
149154 predicate isSource ( DataFlow:: Node node ) {
150- /* 1. Declaring / Initializing an array-type variable */
151- exists ( ArrayAllocation arrayAllocation |
152- node .asExpr ( ) = arrayAllocation .asStackAllocation ( ) .getInitExpr ( )
153- )
154- or
155- /* 2. Allocating dynamic memory as an array */
156- none ( ) // TODO
155+ exists ( ArrayAllocation arrayAllocation | node = arrayAllocation .getNode ( ) )
157156 }
158157
159158 predicate isSink ( DataFlow:: Node node ) {
160159 exists ( PointerFormation pointerFormation | node = pointerFormation .getNode ( ) )
161160 }
162161}
163162
164- module TrackArray = DataFlow:: Global< TrackArrayConfig > ;
163+ import semmle.code.cpp.dataflow.new.TaintTracking
164+ module TrackArray = TaintTracking:: Global< TrackArrayConfig > ;
165165
166166private predicate arrayDeclarationAndAccess (
167167 DataFlow:: Node arrayDeclarationNode , DataFlow:: Node pointerFormationNode
0 commit comments