Null dereferencing of a pointer in initconfig.c

オープン 初心者向け
#160,962 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@lazerg がすでに取り組んでいます。

2026年10月30日 から。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c, python

調査の方向性

Python/initconfig.c 内のリンクされた2か所から始め、NULL値の処理を PyConfig_MEMBER_WSTR_OPT の場合と比較してください。Doc/c-api/init_config.rst の C API ドキュメントを確認し、動作がその契約に一致することと、関連する構成テストが通ることを検証してください。

索引モデルが issue の本文から書いたものです。

説明

interpreter-core topic-C-API type-bug
Bug report

Potentially, if "value" equals NULL and "spec->type" equals "PyConfig_MEMBER_WSTR_OPT", null will be passed into "utf8_to_wstr" function and might cause a segmentation fault in strlen
https://github.com/python/cpython/blob/d3a1e7280bd74a16c5822cff9c77fa28da4d725e/Python/initconfig.c#L4369-L4376
https://github.com/python/cpython/blob/d3a1e7280bd74a16c5822cff9c77fa28da4d725e/Python/initconfig.c#L4324-L4328

Documentation states that "value" is a null-terminated UTF-8 string, but isn't clearly stating that Null is allowed

Suggested fix: separate "value" and "spec->type" checks

if (value == NULL) { 
        if (spec->type != PyConfig_MEMBER_WSTR_OPT) {
               nitconfig_set_error(config, "config option string cannot be NULL");
               return -1;
               }
    wchar_t **member = raw_member;
    free(*member);
    *member = wstr;
    return 0;
}
CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

主要言語
Python
スター
77.8k
フォーク
37.7k
平均マージ
15時間 24分
マージ済み PR(30日)
728

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python/cpython のほかの issue

python/cpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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