system/cle: overlong line executed as a truncated command at EOL
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- c
- 領域
- cli, embedded-iot
調査の方向性
system/cle/cle.c を読んでください。struct cle_s と、印字可能文字とタブを挿入する cle() ループから始め、次に \n がどこで処理され、行がNSHに返されるかを確認します。挿入が収まらなくなったときに設定される bool overflow フラグを追加してください(BELを出力し、読み取りを続ける)。オーバーフロー中に改行を受け取ったら、バッファをクリアし、\r\n をエコーして、OKを返します。検証として、CONFIG_NSH_CLE=y と CONFIG_LINE_MAX=80 を指定して sim:nsh をビルドし、長すぎる poweroff の行に続けて uname -a を入力します。長すぎる行が破棄され、後続のコマンドが実行され、ちょうど収まる行もまだ実行されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Repository: apache/nuttx-apps · Component: system/cle/cle.c (selected by CONFIG_NSH_CLE=y)
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_CLE=y, CONFIG_SYSTEM_CLE=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) — insertion stops at 79 bytes and further bytes ring the bell, but the newline still submits the truncated buffer:
nsh> poweroff AAAA... <- 79 bytes accepted, further bytes rejected with BEL
(process exits with status 0 within 0.5 s; the follow-up command never runs)
The tail of the line is not discarded: it is consumed as new input and runs as further commands (e.g. a run of C characters ends up executed as a command named C).
Expected — the whole line is discarded through EOL and the next command runs:
nsh> poweroff AAAA...<BEL> <- discarded; poweroff is not executed
(empty line returned to NSH)
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 bool overflow to struct cle_s. When a printable or tab character no longer fits, set overflow, emit BEL, and keep consuming bytes without inserting them. On \n while overflowing, clear the buffer, echo \r\n, and return OK so NSH receives an empty line. A line that exactly fits must still execute, and a failed newline insertion alone must not set overflow. The patch changes only system/cle/cle.c.
Patch: 0002-cle-discard-overlong-line.patch, posted in the first comment. It applies to master 7196658dffde (git apply --check returns 0). CLE only covers the interactive editor; NSH script mode still calls readline_fd(), so a product using CLE needs both patches.
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
-
[FEATURE] Shrink getprime runs for OSTest対応中かも @linguini1 が 41 日前に担当しました。 オープンType: Enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
apache/nuttx-apps#3620 · コメント 6 件 · リアクション 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 50/100
apache/nuttx-apps#4107 · コメント 3 件 ·
メンテナーはふだん 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