system/cle: overlong line executed as a truncated command at EOL
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- c
- Lĩnh vực
- cli, embedded-iot
Hướng nghiên cứu
Đọc system/cle/cle.c: bắt đầu từ struct cle_s và vòng lặp cle() chèn các ký tự in được và tab, sau đó tìm nơi \n được xử lý và dòng được trả về cho NSH. Thêm cờ bool overflow được đặt khi việc chèn không còn vừa nữa (phát BEL, tiếp tục đọc). Khi gặp ký tự xuống dòng trong lúc tràn, xóa bộ đệm, phản hồi \r\n và trả về OK. Để kiểm tra, biên dịch sim:nsh với CONFIG_NSH_CLE=y và CONFIG_LINE_MAX=80, rồi nhập một dòng quá dài poweroff tiếp theo là uname -a; hoàn thành khi dòng quá dài bị loại bỏ, lệnh tiếp theo được chạy và dòng vừa khít vẫn được thực thi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C
- Star
- 474
- Fork
- 807
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 181
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/nuttx-apps
-
[FEATURE] Shrink getprime runs for OSTestCó thể đã có người làm @linguini1 đã nhận 41 ngày trước. Đang mởType: Enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
apache/nuttx-apps#3620 · 6 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 50/100
apache/nuttx-apps#4107 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[TODO] move graphics/input -> input.Có thể làm lại được @cederom đã nhận 241 ngày trước và không có pull request nào đang mở. Đang mở
apache/nuttx-apps#3436 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Type: Enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
apache/nuttx-apps#3258 · 1 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Community: Question
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
apache/nuttx-apps#3134 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/nuttx-apps
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
trezor/trezor-firmware#8357 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue kernel
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
JackFurton/who-would-build-a-kernel-in-java#316 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bandwidth selector rotary direction is inconsistent with the regular menu on portable modelsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
PE5PVB/TEF6686_ESP32#970 ·
-
bug sev-3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100