github / github/codeql

False positive "Comparison result is always the same" because of incorrect sizeof evaluation

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

説明

**Description of the false positive**

CodeQL complains "Comparison is always true because i <= 1. "

However, it is really a loop over 4 elements.

I suspect the problem is that
```c
struct foo
{
...
unsigned long (*fnptr_array[4])(void);
...
};
```
describes an array of 4 function pointers, but that CodeQL isn't evaluating `sizeof` correctly on the type.

**Code samples or links to source code**

https://github.com/andyhhp/xtf/blob/f503efe8e5cf8858ec0704f1aaa82d0bf50891a5/tests/swint-emulation/main.c#L162-L162

but I've done a simpler example in https://godbolt.org/z/9fGr51r68 if that helps

**URL to the alert on GitHub code scanning (optional)**

https://github.com/andyhhp/xtf/security/code-scanning/55

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

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

評価

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

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

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