github / github/codeql

[C++] Control Flow Influence not detected interprocedurally

オープン
#18,100 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
question
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 15時間
マージ済み PR(30日)
141

説明

The `controls` predicate from `GuardCondition` does not detect influence across function boundaries. Is this intended behavior?

Here is the code for my example. Influence from `condition` in line 23 is detected but not from line 14.

Similarly the influence on `call()` in line 30 is detected but not on line 8.

```cpp
#include

void call()
{
}

void call_wrapper()
{
call(); // not detected as controlled
}

void check_condition(bool condition)
{
if (condition) // not detected as controlling
{
throw std::exception();
}
}

void my_fn(bool outer, bool condition)
{

if (condition) // detected as controlling
{
throw std::exception();
}

check_condition(condition);

call(); // detected as controlled

call_wrapper();
}
```

```ql
import cpp
import semmle.code.cpp.controlflow.IRGuards

from Variable v, VariableAccess va, GuardCondition cond, Call c, int line
where
c.getTarget().getName() = "call" and
va.getTarget() = v and
v.getName() = "condition" and
cond.getAChild*() = va and
cond.controls(c.getBasicBlock(), _) and
line = va.getLocation().getStartLine()
select v, va, cond, c, line

```

```
| v | va | cond | c | line |
+-----------+-----------+-----------+--------------+------+
| condition | condition | condition | call to call | 23 |
```

CodeQL version: 2.19.3

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。