@@ -96,7 +96,7 @@ int invalidPointerToDereferenceFieldFlowBranchLimit() { result = 0 }
96
96
private module InvalidPointerToDerefBarrier {
97
97
private module BarrierConfig implements DataFlow:: ConfigSig {
98
98
additional predicate isSource ( DataFlow:: Node source , PointerArithmeticInstruction pai ) {
99
- invalidPointerToDerefSource ( _, pai , _, _ ) and
99
+ invalidPointerToDerefSource ( _, pai , _) and
100
100
// source <= pai
101
101
bounded2 ( source .asInstruction ( ) , pai , any ( int d | d <= 0 ) )
102
102
}
@@ -169,11 +169,11 @@ private module InvalidPointerToDerefBarrier {
169
169
*/
170
170
private module InvalidPointerToDerefConfig implements DataFlow:: StateConfigSig {
171
171
class FlowState extends PointerArithmeticInstruction {
172
- FlowState ( ) { invalidPointerToDerefSource ( _, this , _, _ ) }
172
+ FlowState ( ) { invalidPointerToDerefSource ( _, this , _) }
173
173
}
174
174
175
175
predicate isSource ( DataFlow:: Node source , FlowState pai ) {
176
- invalidPointerToDerefSource ( _, pai , source , _ )
176
+ invalidPointerToDerefSource ( _, pai , source )
177
177
}
178
178
179
179
pragma [ inline]
@@ -201,16 +201,14 @@ private import DataFlow::GlobalWithState<InvalidPointerToDerefConfig>
201
201
* left-hand side of the pointer-arithmetic instruction represented by `derefSource`.
202
202
*/
203
203
private predicate invalidPointerToDerefSource (
204
- DataFlow:: Node allocSource , PointerArithmeticInstruction pai , DataFlow:: Node derefSource ,
205
- int deltaDerefSourceAndPai
204
+ DataFlow:: Node allocSource , PointerArithmeticInstruction pai , DataFlow:: Node derefSource
206
205
) {
207
206
// Note that `deltaDerefSourceAndPai` is not necessarily equal to `rhsSizeDelta`:
208
207
// `rhsSizeDelta` is the constant offset added to the size of the allocation, and
209
208
// `deltaDerefSourceAndPai` is the constant difference between the pointer-arithmetic instruction
210
209
// and the instruction computing the address for which we will search for a dereference.
211
210
AllocToInvalidPointer:: pointerAddInstructionHasBounds ( allocSource , pai , _, _) and
212
- derefSource .asInstruction ( ) = pai and
213
- deltaDerefSourceAndPai = 0
211
+ derefSource .asInstruction ( ) = pai
214
212
}
215
213
216
214
/**
@@ -253,11 +251,9 @@ private Instruction getASuccessor(Instruction instr) {
253
251
instr .getBlock ( ) .getASuccessor + ( ) = result .getBlock ( )
254
252
}
255
253
256
- private predicate paiForDereferenceSink (
257
- PointerArithmeticInstruction pai , DataFlow:: Node derefSink , int deltaDerefSourceAndPai
258
- ) {
254
+ private predicate paiForDereferenceSink ( PointerArithmeticInstruction pai , DataFlow:: Node derefSink ) {
259
255
exists ( DataFlow:: Node derefSource |
260
- invalidPointerToDerefSource ( _, pai , derefSource , deltaDerefSourceAndPai ) and
256
+ invalidPointerToDerefSource ( _, pai , derefSource ) and
261
257
flow ( derefSource , derefSink )
262
258
)
263
259
}
@@ -269,10 +265,10 @@ private predicate paiForDereferenceSink(
269
265
*/
270
266
private predicate derefSinkToOperation (
271
267
DataFlow:: Node derefSink , PointerArithmeticInstruction pai , DataFlow:: Node operation ,
272
- string description , int deltaDerefSourceAndPai , int deltaDerefSinkAndDerefAddress
268
+ string description , int deltaDerefSinkAndDerefAddress
273
269
) {
274
270
exists ( Instruction operationInstr , AddressOperand addr |
275
- paiForDereferenceSink ( pai , pragma [ only_bind_into ] ( derefSink ) , deltaDerefSourceAndPai ) and
271
+ paiForDereferenceSink ( pai , pragma [ only_bind_into ] ( derefSink ) ) and
276
272
isInvalidPointerDerefSink ( derefSink , addr , operationInstr , description ,
277
273
deltaDerefSinkAndDerefAddress ) and
278
274
operationInstr = getASuccessor ( derefSink .asInstruction ( ) ) and
@@ -293,11 +289,7 @@ predicate operationIsOffBy(
293
289
DataFlow:: Node allocation , PointerArithmeticInstruction pai , DataFlow:: Node derefSource ,
294
290
DataFlow:: Node derefSink , string description , DataFlow:: Node operation , int delta
295
291
) {
296
- exists ( int deltaDerefSourceAndPai , int deltaDerefSinkAndDerefAddress |
297
- invalidPointerToDerefSource ( allocation , pai , derefSource , deltaDerefSourceAndPai ) and
298
- flow ( derefSource , derefSink ) and
299
- derefSinkToOperation ( derefSink , pai , operation , description , deltaDerefSourceAndPai ,
300
- deltaDerefSinkAndDerefAddress ) and
301
- delta = deltaDerefSourceAndPai + deltaDerefSinkAndDerefAddress
302
- )
292
+ invalidPointerToDerefSource ( allocation , pai , derefSource ) and
293
+ flow ( derefSource , derefSink ) and
294
+ derefSinkToOperation ( derefSink , pai , operation , description , delta )
303
295
}
0 commit comments