uniq: overflowing -f/-s/-w values with trailing garbage are silently accepted
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
- 75/100
Direzione di ricerca
Il bug si trova in opt_parsed in src/uu/uniq/src/uniq.rs (intorno alle righe 355-360), che associa ogni errore di parsing PosOverflow a usize::MAX. Inizia riproducendo il problema con cargo build -p uu_uniq e il comando printf/-f dell'issue, poi controlla il percorso di overflow. È completato quando un numero che va in overflow seguito da caratteri spuri viene rifiutato con il messaggio GNU "invalid number of fields to skip" e exit code 1, mentre un numero valido ma troppo grande come 18446744073709551616 continua a essere accettato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
uniq accepts a malformed numeric option when the digit prefix overflows usize before the parser reaches an invalid suffix. With -f or -s, it then skips the entire comparison key and collapses distinct input lines into one, exiting successfully instead of rejecting the argument.
Verified on Linux x86_64 (Debian 13), LC_ALL=C LANG=C, using uutils 0.13.0 built from main at 9cc868bcab387842ea2fa7b8e85c76e05860c51f. Compared with GNU coreutils 9.12 from the reference package linked in CONTRIBUTING.md, and GNU 9.7.
Reproduction
From the repository root:
cargo build --locked -p uu_uniq
export LC_ALL=C LANG=C
printf 'first\nsecond\nthird\n' | target/debug/uniq -f 18446744073709551616x
printf 'status=%s\n' "$?"
Actual stdout:
first
status=0
Stderr is empty. GNU 9.12 and 9.7 produce no filtered output, report "18446744073709551616x: invalid number of fields to skip", and exit 1.
Replacing -f with -s also incorrectly prints only first and exits 0. With -w, uutils accepts the malformed count and prints all three lines with status 0; GNU rejects it.
Control cases on x86_64:
- 18446744073709551616 without the x is accepted by both implementations. A valid oversized count should remain accepted.
- 18446744073709551615x is rejected by both. Adding one to the numeric prefix causes uutils to stop rejecting the invalid suffix.
Cause
opt_parsed in uniq.rs:355-360 converts every PosOverflow parse error into usize::MAX. Integer parsing can report overflow before examining the rest of the string, so this does not establish that the complete argument is numeric. Validate the entire argument before accepting an overflowing value.
No matching report was found in searches of open and closed issues and relevant PRs. Related #15970 concerns error wording for values that are already rejected. Its PR #15971 retains the unconditional PosOverflow acceptance, so this is a separate validation problem.
- Lingua principale
- Rust
- Stelle
- 24.3k
- Fork
- 2.1k
- Merge medio
- 1g 22h
- PR unite (30g)
- 396
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la 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 uutils/coreutils
-
U - od
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
U - pr
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
U - nl
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
U - unexpand
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di uutils/coreutils
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
GiganticMinecraft/seichi-portal-backend#1651 ·
I maintainer di solito rispondono entro 1 giorno
-
Android visitors are offered the Linux .deb on cap.so's homepage and download pageForse già presa @patrickballard l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
CapSoftware/Cap#3677 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno