system/readline: overlong NSH line runs as a truncated prefix
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 50/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- c
- 領域
- cli, operating-systems
調査の方向性
Read system/readline/readline_common.c, especially the readline_common() character loop where a received byte plus the terminating NUL fills CONFIG_LINE_MAX. Reproduce on sim:nsh by feeding poweroff plus 200 As and a newline; confirm the 79-byte prefix is submitted. Done means an overlong line emits BEL, discards through newline/CR and EOF, resets the buffer, returns 0, while a line of exactly LINE_MAX - 1 bytes still runs. The patch in the first comment is a reference, not something a newcomer should duplicate.
索引モデルが issue の本文から書いたものです。
説明
Repository: apache/nuttx-apps · Component: system/readline/readline_common.c (used by NSH)
Environment: NuttX Apps 13.1.0, also master 7196658dffde; host sim:nsh (not QEMU, not a board); Linux x86_64, gcc 11.4; CONFIG_NSH_READLINE=y, CONFIG_READLINE_EDIT=y, CONFIG_LINE_MAX=80 (79 usable bytes).
Repro
- Build
sim:nshwith the configuration above. - Write
powerofffollowed by 200Aand\nto stdin. - After 0.5 s write
uname -a\n, then observe whether the process is still alive and whether the follow-up command runs. The test driver kills the process after a 2 s timeout if it did not exit on its own.
Actual (stock 13.1.0) — when the buffer fills, the 79-byte prefix is submitted as a command, so poweroff runs before the newline is ever seen:
nsh> poweroff AAAA... <- 79-byte prefix submitted at buffer full
(process exits with status 0 within 0.5 s; the follow-up command never runs)
The remaining bytes are not discarded either: they are read as further input and parsed as additional commands, so the tail of a single long line also executes.
Expected — the whole line is discarded through EOL and the next command runs:
nsh> poweroff AAAA...<BEL> <- discarded; poweroff is not executed
nsh> uname -a
NuttX ... sim sim <- follow-up command runs normally
(process stays alive; the harness kills it after the 2 s timeout)
Fix suggestion: add an overflow state in readline_common(). When a character plus the NUL no longer fits, emit BEL and drop every byte until \n/\r; then clear the buffer and return 0. On EOF while overflowing, discard the partial line and return 0. A line that exactly fills the buffer (LINE_MAX - 1 bytes) must still execute. The patch changes only system/readline/readline_common.c.
Patch: 0001-readline-discard-overlong-line.patch, posted in the first comment. It applies to master 7196658dffde (git apply --check returns 0). A companion report covers the same consequence in the other NSH frontend, system/cle/cle.c.
Reported from an audit of NSH input handling. Patch is in the first comment; happy to rework it if maintainers prefer a different approach.
- 主要言語
- C
- スター
- 474
- フォーク
- 807
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 181
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/nuttx-apps のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/nuttx-apps#4108 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
[FEATURE] Shrink getprime runs for OSTest対応中かも @linguini1 が 41 日前に担当しました。 オープンType: Enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
apache/nuttx-apps#3620 · コメント 6 件 · リアクション 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[TODO] move graphics/input -> input.再び着手できるかも @cederom が 241 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
apache/nuttx-apps#3436 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Type: Enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
apache/nuttx-apps#3258 · コメント 1 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Community: Question
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
apache/nuttx-apps#3134 ·
メンテナーはふだん 1 日以内に返信
apache/nuttx-apps の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
trezor/trezor-firmware#8357 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
good first issue kernel
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
JackFurton/who-would-build-a-kernel-in-java#316 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
PE5PVB/TEF6686_ESP32#970 ·
-
bug sev-3
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100