11import semmle.code.cpp.ir.dataflow.DataFlow
22private import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate
33private import semmle.code.cpp.ir.dataflow.internal.DataFlowUtil
4+ private import semmle.code.cpp.ir.dataflow.internal.DataFlowImplCommon
45private import codeql.util.Unit
56
67module ProductFlow {
@@ -363,7 +364,40 @@ module ProductFlow {
363364 TOutOf ( DataFlowCall call ) {
364365 [ any ( Flow1:: PathNode n ) .getNode ( ) , any ( Flow2:: PathNode n ) .getNode ( ) ] .( OutNode ) .getCall ( ) =
365366 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+ }
367401
368402 pragma [ nomagic]
369403 private predicate interprocEdge1 (
@@ -374,14 +408,14 @@ module ProductFlow {
374408 predDecl != succDecl and
375409 pred1 .getNode ( ) .getEnclosingCallable ( ) = predDecl and
376410 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 )
381413 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 , _)
385419 )
386420 }
387421
@@ -394,14 +428,14 @@ module ProductFlow {
394428 predDecl != succDecl and
395429 pred2 .getNode ( ) .getEnclosingCallable ( ) = predDecl and
396430 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 )
401433 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 , _)
405439 )
406440 }
407441
0 commit comments