system/readline: overlong NSH line runs as a truncated prefix
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 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 小时
- 30 天内合并 PR
- 181
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 个 reaction · 已指派 1 人 ·
维护者通常 1 天内回复
-
[TODO] move graphics/input -> input.可能重新可做 @cederom 于 241 天前认领,目前没有进行中的 PR。 未关闭
apache/nuttx-apps#3436 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Type: Enhancement
难度 5/5 一周以上 新手友好度 35/100
apache/nuttx-apps#3258 · 1 条评论 · 2 个 reaction ·
维护者通常 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