Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

env: a NUL byte in a `--file` entry reaches `std::env::set_var` unvalidated and aborts the process (exit 134)

Aperta Adatta ai principianti
#14,490 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

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
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
cli

Direzione di ricerca

Inizia in src/uu/env/src/env.rs intorno alle righe 331-338 e segui il percorso --file dalle voci analizzate fino a std::env::set_var; confrontalo con apply_specified_env_vars, che protegge il percorso argv. Riproduci i casi NUL per chiave e valore riportati nell'issue, quindi verifica che entrambi producano una diagnostica e un errore senza panic invece di terminare con exit 134.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

U - env

env --file FILE parses an .env/INI file and passes each key and value straight to std::env::set_var, which panics when either contains a NUL byte. A single NUL anywhere in the file therefore aborts env with a Rust panic instead of a diagnostic.

The argv path (env NAME=VALUE ...) is guarded — apply_specified_env_vars checks for an empty name before calling set_var, but the --file path has no guard at all.

Steps to reproduce

A NUL in the value:

$ printf 'KEY=a\x00b\n' > conf.env
$ env --file conf.env
thread 'main' panicked at library/std/src/env.rs:361:9:
failed to set environment variable `"KEY"` to `"a\0b"`: file name contained an unexpected NUL byte
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo $?
134

A NUL in the key does the same:

$ printf 'a\x00b=c\n' > k.env
$ env --file k.env       # exit 134, identical panic

Root cause

https://github.com/uutils/coreutils/blob/2c0e1b981fdce56bb8cc729dffed702ff0410e8e/src/uu/env/src/env.rs#L331-L338

std::env::set_var panics if either argument contains a NUL. Nothing between the parser and this call validates the bytes.

Lingua principale
Rust
Stelle
24.2k
Fork
2.1k
Merge medio
1g 17h
PR unite (30g)
331

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di uutils/coreutils

Tutte le issue di uutils/coreutils

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.