system/cle: overlong line executed as a truncated command at EOL
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 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 小时
- 30 天内合并 PR
- 181
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 个 reaction · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 50/100
apache/nuttx-apps#4107 · 3 条评论 ·
维护者通常 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