1
1
import semmle.code.cpp.ir.dataflow.DataFlow
2
2
private import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate
3
3
private import semmle.code.cpp.ir.dataflow.internal.DataFlowUtil
4
+ private import semmle.code.cpp.ir.dataflow.internal.DataFlowImplCommon
4
5
private import codeql.util.Unit
5
6
6
7
module ProductFlow {
@@ -363,7 +364,40 @@ module ProductFlow {
363
364
TOutOf ( DataFlowCall call ) {
364
365
[ any ( Flow1:: PathNode n ) .getNode ( ) , any ( Flow2:: PathNode n ) .getNode ( ) ] .( OutNode ) .getCall ( ) =
365
366
call
366
- }
367
+ } or
368
+ TJump ( )
369
+
370
+ private predicate into1 ( Flow1:: PathNode pred1 , Flow1:: PathNode succ1 , TKind kind ) {
371
+ exists ( DataFlowCall call |
372
+ kind = TInto ( call ) and
373
+ pred1 .getNode ( ) .( ArgumentNode ) .getCall ( ) = call and
374
+ succ1 .getNode ( ) instanceof ParameterNode
375
+ )
376
+ }
377
+
378
+ private predicate out1 ( Flow1:: PathNode pred1 , Flow1:: PathNode succ1 , TKind kind ) {
379
+ exists ( ReturnKindExt returnKind , DataFlowCall call |
380
+ kind = TOutOf ( call ) and
381
+ succ1 .getNode ( ) = returnKind .getAnOutNode ( call ) and
382
+ pred1 .getNode ( ) .( ReturnNodeExt ) .getKind ( ) = returnKind
383
+ )
384
+ }
385
+
386
+ private predicate into2 ( Flow2:: PathNode pred1 , Flow2:: PathNode succ1 , TKind kind ) {
387
+ exists ( DataFlowCall call |
388
+ kind = TInto ( call ) and
389
+ pred1 .getNode ( ) .( ArgumentNode ) .getCall ( ) = call and
390
+ succ1 .getNode ( ) instanceof ParameterNode
391
+ )
392
+ }
393
+
394
+ private predicate out2 ( Flow2:: PathNode pred1 , Flow2:: PathNode succ1 , TKind kind ) {
395
+ exists ( ReturnKindExt returnKind , DataFlowCall call |
396
+ kind = TOutOf ( call ) and
397
+ succ1 .getNode ( ) = returnKind .getAnOutNode ( call ) and
398
+ pred1 .getNode ( ) .( ReturnNodeExt ) .getKind ( ) = returnKind
399
+ )
400
+ }
367
401
368
402
pragma [ nomagic]
369
403
private predicate interprocEdge1 (
@@ -374,14 +408,14 @@ module ProductFlow {
374
408
predDecl != succDecl and
375
409
pred1 .getNode ( ) .getEnclosingCallable ( ) = predDecl and
376
410
succ1 .getNode ( ) .getEnclosingCallable ( ) = succDecl and
377
- exists ( DataFlowCall call |
378
- kind = TInto ( call ) and
379
- pred1 .getNode ( ) .( ArgumentNode ) .getCall ( ) = call and
380
- succ1 .getNode ( ) instanceof ParameterNode
411
+ (
412
+ into1 ( pred1 , succ1 , kind )
381
413
or
382
- kind = TOutOf ( call ) and
383
- succ1 .getNode ( ) .( OutNode ) .getCall ( ) = call and
384
- pred1 .getNode ( ) instanceof ReturnNode
414
+ out1 ( pred1 , succ1 , kind )
415
+ or
416
+ kind = TJump ( ) and
417
+ not into1 ( pred1 , succ1 , _) and
418
+ not out1 ( pred1 , succ1 , _)
385
419
)
386
420
}
387
421
@@ -394,14 +428,14 @@ module ProductFlow {
394
428
predDecl != succDecl and
395
429
pred2 .getNode ( ) .getEnclosingCallable ( ) = predDecl and
396
430
succ2 .getNode ( ) .getEnclosingCallable ( ) = succDecl and
397
- exists ( DataFlowCall call |
398
- kind = TInto ( call ) and
399
- pred2 .getNode ( ) .( ArgumentNode ) .getCall ( ) = call and
400
- succ2 .getNode ( ) instanceof ParameterNode
431
+ (
432
+ into2 ( pred2 , succ2 , kind )
401
433
or
402
- kind = TOutOf ( call ) and
403
- succ2 .getNode ( ) .( OutNode ) .getCall ( ) = call and
404
- pred2 .getNode ( ) instanceof ReturnNode
434
+ out2 ( pred2 , succ2 , kind )
435
+ or
436
+ kind = TJump ( ) and
437
+ not into2 ( pred2 , succ2 , _) and
438
+ not out2 ( pred2 , succ2 , _)
405
439
)
406
440
}
407
441
0 commit comments