|
1 | 1 | import semmle.code.cpp.ir.dataflow.DataFlow
|
| 2 | +private import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate |
| 3 | +private import semmle.code.cpp.ir.dataflow.internal.DataFlowUtil |
2 | 4 | private import codeql.util.Unit
|
3 | 5 |
|
4 | 6 | module ProductFlow {
|
@@ -352,32 +354,63 @@ module ProductFlow {
|
352 | 354 | pragma[only_bind_out](succ.getNode().getEnclosingCallable())
|
353 | 355 | }
|
354 | 356 |
|
| 357 | + newtype TKind = |
| 358 | + TInto(DataFlowCall call) { |
| 359 | + [any(Flow1::PathNode n).getNode(), any(Flow2::PathNode n).getNode()] |
| 360 | + .(ArgumentNode) |
| 361 | + .getCall() = call |
| 362 | + } or |
| 363 | + TOutOf(DataFlowCall call) { |
| 364 | + [any(Flow1::PathNode n).getNode(), any(Flow2::PathNode n).getNode()].(OutNode).getCall() = |
| 365 | + call |
| 366 | + } |
| 367 | + |
355 | 368 | pragma[nomagic]
|
356 | 369 | private predicate interprocEdge1(
|
357 |
| - Declaration predDecl, Declaration succDecl, Flow1::PathNode pred1, Flow1::PathNode succ1 |
| 370 | + Declaration predDecl, Declaration succDecl, Flow1::PathNode pred1, Flow1::PathNode succ1, |
| 371 | + TKind kind |
358 | 372 | ) {
|
359 | 373 | Flow1::PathGraph::edges(pred1, succ1) and
|
360 | 374 | predDecl != succDecl and
|
361 | 375 | pred1.getNode().getEnclosingCallable() = predDecl and
|
362 |
| - succ1.getNode().getEnclosingCallable() = succDecl |
| 376 | + 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 |
| 381 | + or |
| 382 | + kind = TOutOf(call) and |
| 383 | + succ1.getNode().(OutNode).getCall() = call and |
| 384 | + pred1.getNode() instanceof ReturnNode |
| 385 | + ) |
363 | 386 | }
|
364 | 387 |
|
365 | 388 | pragma[nomagic]
|
366 | 389 | private predicate interprocEdge2(
|
367 |
| - Declaration predDecl, Declaration succDecl, Flow2::PathNode pred2, Flow2::PathNode succ2 |
| 390 | + Declaration predDecl, Declaration succDecl, Flow2::PathNode pred2, Flow2::PathNode succ2, |
| 391 | + TKind kind |
368 | 392 | ) {
|
369 | 393 | Flow2::PathGraph::edges(pred2, succ2) and
|
370 | 394 | predDecl != succDecl and
|
371 | 395 | pred2.getNode().getEnclosingCallable() = predDecl and
|
372 |
| - succ2.getNode().getEnclosingCallable() = succDecl |
| 396 | + 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 |
| 401 | + or |
| 402 | + kind = TOutOf(call) and |
| 403 | + succ2.getNode().(OutNode).getCall() = call and |
| 404 | + pred2.getNode() instanceof ReturnNode |
| 405 | + ) |
373 | 406 | }
|
374 | 407 |
|
375 | 408 | private predicate interprocEdgePair(
|
376 | 409 | Flow1::PathNode pred1, Flow2::PathNode pred2, Flow1::PathNode succ1, Flow2::PathNode succ2
|
377 | 410 | ) {
|
378 |
| - exists(Declaration predDecl, Declaration succDecl | |
379 |
| - interprocEdge1(predDecl, succDecl, pred1, succ1) and |
380 |
| - interprocEdge2(predDecl, succDecl, pred2, succ2) |
| 411 | + exists(Declaration predDecl, Declaration succDecl, TKind kind | |
| 412 | + interprocEdge1(predDecl, succDecl, pred1, succ1, kind) and |
| 413 | + interprocEdge2(predDecl, succDecl, pred2, succ2, kind) |
381 | 414 | )
|
382 | 415 | }
|
383 | 416 |
|
|
0 commit comments