Potential integer overflow when using atoi() In cgi-bin/var.c
メンテナーはふだん 1 日以内に返信
@michaelrsweet がすでに取り組んでいます。
2026年10月23日 から。
評価
調査の方向性
cgi-bin/var.c の990-992行目付近にある接尾辞解析コードから始めてください。ここでは atoi() が最後の - の後ろの数値を変換し、配列インデックスに渡しています。次に cgiSetArray() の459行目付近にある範囲チェックを確認してください。atoi() の呼び出しを strtol() に置き換え、呼び出しの前に errno をリセットし、errno が ERANGE の場合や、結果が受け入れ可能なインデックス範囲外になる場合は、int にキャストする前に値を拒否してください。この経路上に atoi() が残っておらず、範囲外の接尾辞が変換より前に拒否されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Potential problem
In cgi-bin/var.c, the numeric suffix of a form field name (the part after the last -) is converted with atoi() and used as an array index:
If the value exceeds INT_MAX, converting it with atoi() results in undefined behavior. The subsequent atoi(ptr) - 1 may also overflow.
The practical impact appears limited because cgiSetArray() rejects indexes outside the 0..100000 range:
However, this check is performed only after atoi() has already processed the input, so it cannot make the conversion itself safe. Since the behavior of an out-of-range atoi() conversion is undefined, the result cannot be reliably validated by the subsequent range check and could potentially fall within the accepted range.
Possible solution
Replace atoi() with strtol(), reset errno before the conversion, and validate both errno != ERANGE and the parsed value against the expected range before converting it to int.
Found by Linux Verification Center (portal.linuxtesting.ru) with SVACE.
Author: Stanislav Pichugin <[email protected]>.
- 主要言語
- C
- スター
- 1.8k
- フォーク
- 352
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 16
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OpenPrinting/cups のほかの issue
-
Don't use xgettext sort option (-s) when generating POT file対応中かも @michaelrsweet が 9 日前に担当しました。 オープンinvestigating
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
OpenPrinting/cups#1721 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
OpenPrinting/cups#1786 ·
メンテナーはふだん 1 日以内に返信
-
`lp` (and other libcups clients) send `print-color-mode=<default>` alongside `ColorModel=Gray`, defeating the b0f1a00 "Don't override ColorModel" fix対応中かも @michaelrsweet が 3 日前に担当しました。 オープンinvestigating
難易度 4/5 1〜2日 初心者へのやさしさ 55/100
OpenPrinting/cups#1778 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
OpenPrinting/cups#1726 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ippeveprinter: collection-valued job attributes are never exported to the command (IPP_MEDIA_COL always empty)対応中かも @michaelrsweet が 26 日前に担当しました。 オープンbug documentation priority-low
OpenPrinting/cups#1725 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
OpenPrinting/cups の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ChefKissInc/Inferno#319 ·
-
llvm-tools
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
llvm/llvm-project#235522 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
priority:medium type:chore
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
crazy-goat/php-fpm-ng#1041 ·
メンテナーはふだん 1 日以内に返信