github / github/codeql

False positives - cpp/unbounded-write

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

説明

**Description of the false positive**

CodeQL reports false positives from `cpp/unbounded-write` when the destination buffer passed to `strcpy()` has been allocated to be big enough to fit the string according to `strlen()`.

**Code samples or links to source code**

Here is an example from the OpenZFS source code:

```
int len = strlen(drrb->drr_toname);
cp = umem_alloc(len + 2, UMEM_NOFAIL);
cp[0] = '/';
(void) strcpy(&cp[1], drrb->drr_toname);
```

We allocate `cp` to be 2 larger than the length of `drrb->drr_toname`. Then we do a `strcpy()` command that is guaranteed to be safe.

That is from report 783 below.

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

https://github.com/ryao/zfs/security/code-scanning/782
https://github.com/ryao/zfs/security/code-scanning/783
https://github.com/ryao/zfs/security/code-scanning/784

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

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

評価

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

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

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