@@ -80,26 +80,29 @@ private class ArrayUpdate extends Expr {
80
80
Expr getArray ( ) { result = array }
81
81
}
82
82
83
- /**
84
- * A config that tracks dataflow from creating an array to an operation that updates it.
85
- */
86
- private module ArrayUpdateConfig implements DataFlow:: ConfigSig {
87
- predicate isSource ( DataFlow:: Node source ) { source .asExpr ( ) instanceof StaticByteArrayCreation }
88
-
89
- predicate isSink ( DataFlow:: Node sink ) { sink .asExpr ( ) = any ( ArrayUpdate upd ) .getArray ( ) }
83
+ private predicate arrayUpdateSrc ( DataFlow:: Node source ) {
84
+ source .asExpr ( ) instanceof StaticByteArrayCreation
85
+ }
90
86
91
- predicate isBarrierOut ( DataFlow:: Node node ) { isSink ( node ) }
87
+ private predicate arrayUpdateSink ( DataFlow:: Node sink ) {
88
+ sink .asExpr ( ) = any ( ArrayUpdate upd ) .getArray ( )
92
89
}
93
90
94
- private module ArrayUpdateFlow = DataFlow:: Global< ArrayUpdateConfig > ;
91
+ private module ArrayUpdateFlowFwd = DataFlow:: SimpleGlobal< arrayUpdateSrc / 1 > ;
92
+
93
+ private module ArrayUpdateFlow = ArrayUpdateFlowFwd:: Graph< arrayUpdateSink / 1 > ;
94
+
95
+ private predicate arrayReachesUpdate ( StaticByteArrayCreation array ) {
96
+ exists ( ArrayUpdateFlow:: PathNode src | src .isSource ( ) and src .getNode ( ) .asExpr ( ) = array )
97
+ }
95
98
96
99
/**
97
100
* A source that defines an array that doesn't get updated.
98
101
*/
99
102
private class StaticInitializationVectorSource extends DataFlow:: Node {
100
103
StaticInitializationVectorSource ( ) {
101
104
exists ( StaticByteArrayCreation array | array = this .asExpr ( ) |
102
- not ArrayUpdateFlow :: flow ( DataFlow :: exprNode ( array ) , _ ) and
105
+ not arrayReachesUpdate ( array ) and
103
106
// Reduce FPs from utility methods that return an empty array in an exceptional case
104
107
not exists ( ReturnStmt ret |
105
108
array .getADimension ( ) .( CompileTimeConstantExpr ) .getIntValue ( ) = 0 and
0 commit comments