-Wstringop-truncation warning in socketmodule.c getsockaddrarg() for AF_ALG salg_name
オープン
まだ誰も着手していません。
extension-modules
pending
topic-socket
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
Building 3.14.5 with gcc 15.2 produces this warning:
default: ./Modules/socketmodule.c: In function ‘getsockaddrarg’:
default: ./Modules/socketmodule.c:2636:9: warning: ‘strncpy’ specified bound 64 equals destination size [-Wstringop-truncation]
default: 2636 | strncpy((char *)sa->salg_name, name, sizeof(sa->salg_name));
default: | ^
Build environment: Ubuntu 26.04 LTS, gcc 15.2.0, configure with
./configure --enable-optimizations --with-lto --enable-bolt --enable-safety --enable-slower-safety --with-system-expat CXX=/usr/bin/g++ CFLAGS="-flto=auto" LDFLAGS="-flto=auto"
This looks like a false positive. I see this location reported in https://github.com/python/cpython/issues/94536 and there is a fix for a similar warning here:
https://github.com/matthiasgoergens/cpython/commit/c1fdddcf0f7b31a5954163bfd299115b1fa7799b
Would the following be a good fix that mirrors that older one?
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy((char *)sa->salg_name, name, sizeof(sa->salg_name));
#pragma GCC diagnostic pop
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
- gh-150022
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Modules/socketmodule.c の AF_ALG に対する getsockaddrarg() の処理から始め、報告された strncpy 警告を調査してください。関連する CPython issue とリンクされている PR gh-150022 を確認し、そのうえで報告された GCC ビルドにより、ソケットの動作を変更せずに警告が解消されていることを検証してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c
- 領域
- networking
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100