system/cle: overlong line executed as a truncated command at EOL
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- c
- Ambito
- cli, embedded-iot
Direzione di ricerca
Leggi system/cle/cle.c: inizia da struct cle_s e dal ciclo cle() che inserisce caratteri stampabili e tabulazioni, poi trova dove viene gestito \n e dove la riga viene restituita a NSH. Aggiungi un flag bool overflow che viene impostato quando l'inserimento non entra più (emetti BEL, continua a consumare). Su un newline durante l'overflow, svuota il buffer, ripeti \r\n e restituisci OK. Per verificare, compila sim:nsh con CONFIG_NSH_CLE=y e CONFIG_LINE_MAX=80 e invia una riga troppo lunga poweroff seguita da uname -a; è fatto quando la riga troppo lunga viene scartata, il comando successivo viene eseguito e una riga che entra esattamente viene ancora eseguita.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C
- Stelle
- 474
- Fork
- 807
- Merge medio
- 1g 11h
- PR unite (30g)
- 181
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/nuttx-apps
-
[FEATURE] Shrink getprime runs for OSTestForse già presa @linguini1 l’ha presa 41 giorni fa. ApertaType: Enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
apache/nuttx-apps#3620 · 6 commenti · 1 reazione · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 50/100
apache/nuttx-apps#4107 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[TODO] move graphics/input -> input.Forse di nuovo libera @cederom l’ha presa 241 giorni fa e non c’è nessuna pull request aperta. Aperta
apache/nuttx-apps#3436 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Type: Enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
apache/nuttx-apps#3258 · 1 commento · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Community: Question
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
apache/nuttx-apps#3134 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/nuttx-apps
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
trezor/trezor-firmware#8357 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue kernel
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
JackFurton/who-would-build-a-kernel-in-java#316 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
PE5PVB/TEF6686_ESP32#970 ·
-
bug sev-3
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100