@@ -134,16 +134,34 @@ module StringSizeConfig implements ProductFlow::StateConfigSig {
134
134
135
135
module StringSizeFlow = ProductFlow:: GlobalWithState< StringSizeConfig > ;
136
136
137
+ int getOverflow (
138
+ DataFlow:: Node source1 , DataFlow:: Node source2 , DataFlow:: Node sink1 , DataFlow:: Node sink2 ,
139
+ CallInstruction c , Expr buffer
140
+ ) {
141
+ result > 0 and
142
+ exists (
143
+ StringSizeFlow:: PathNode1 pathSource1 , StringSizeFlow:: PathNode2 pathSource2 ,
144
+ StringSizeFlow:: PathNode1 pathSink1 , StringSizeFlow:: PathNode2 pathSink2
145
+ |
146
+ StringSizeFlow:: flowPath ( pathSource1 , pathSource2 , pathSink1 , pathSink2 ) and
147
+ source1 = pathSource1 .getNode ( ) and
148
+ source2 = pathSource2 .getNode ( ) and
149
+ sink1 = pathSink1 .getNode ( ) and
150
+ sink2 = pathSink2 .getNode ( ) and
151
+ isSinkPairImpl ( c , sink1 , sink2 , result + pathSink2 .getState ( ) , buffer )
152
+ )
153
+ }
154
+
137
155
from
138
156
StringSizeFlow:: PathNode1 source1 , StringSizeFlow:: PathNode2 source2 ,
139
- StringSizeFlow:: PathNode1 sink1 , StringSizeFlow:: PathNode2 sink2 , int overflow , int sinkState ,
140
- CallInstruction c , DataFlow :: Node sourceNode , Expr buffer , string element
157
+ StringSizeFlow:: PathNode1 sink1 , StringSizeFlow:: PathNode2 sink2 , int overflow , CallInstruction c ,
158
+ Expr buffer , string element
141
159
where
142
160
StringSizeFlow:: flowPath ( source1 , source2 , sink1 , sink2 ) and
143
- sinkState = sink2 . getState ( ) and
144
- isSinkPairImpl ( c , sink1 .getNode ( ) , sink2 .getNode ( ) , overflow + sinkState , buffer ) and
145
- overflow > 0 and
146
- sourceNode = source1 . getNode ( ) and
161
+ overflow =
162
+ max ( getOverflow ( source1 . getNode ( ) , source2 . getNode ( ) , sink1 .getNode ( ) , sink2 .getNode ( ) , c ,
163
+ buffer )
164
+ ) and
147
165
if overflow = 1 then element = " element." else element = " elements."
148
166
select c .getUnconvertedResultExpression ( ) , source1 , sink1 ,
149
167
"This write may overflow $@ by " + overflow + element , buffer , buffer .toString ( )
0 commit comments