Rust API: a path component with an interior NUL byte is silently truncated instead of rejected
Una pull request collegata è già stata integrata.
- #437 di @cyphar — integrata
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 18/100
Direzione di ricerca
The truncation happens in the ToCString for OsStr conversion, which uses take_while to stop at the first NUL byte; start there and follow it into the create_file and resolve_nofollow call paths. Done means a path with an interior NUL returns an error instead of being cut short, with a regression test covering both calls. A linked open pull request (#437) already targets this, so check it before starting any work.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
ToCString for OsStr builds the C string with take_while(|&c| c != b'\0'), so a Path containing a NUL is cut off at the NUL and the operation runs on the shorter path:
let tmp = tempfile::tempdir()?;
std::fs::create_dir(tmp.path().join("etc"))?;
std::fs::create_dir(tmp.path().join("data"))?;
let root = Root::open(tmp.path())?;
// Creates <tmp>/etc/file and returns Ok: the parent `etc\0x` became `etc`.
root.create_file(Path::new("etc\0x/file"), OpenFlags::O_WRONLY, &Permissions::from_mode(0o644))?;
assert!(tmp.path().join("etc/file").exists());
// Returns a handle to <tmp>/data: the name `data\0bad` became `data`.
let handle = root.resolve_nofollow(Path::new("data\0bad"))?;
This is surprising behavior compared to std::fs, cap-std, rustix etc which all validate and reject paths with NUL bytes. Users wanting to avoid this behavior are forced to wrap pathrs and reject NUL bytes themselves.
- Lingua principale
- Rust
- Stelle
- 146
- Fork
- 12
- Merge medio
- 2g 16h
- PR unite (30g)
- 5
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun 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 cyphar/libpathrs
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
rust tests
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
-
api/procfs linux/upstream
Difficoltà 4/5 3-5 giorni Idoneità per principianti 44/100
-
api/cffi bindings/go bindings/python ideas welcome
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
linux/upstream
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Tutte le issue di cyphar/libpathrs
Issue simili
-
type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
stackabletech/operator-rs#1301 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
jmcnamara/rust_xlsxwriter#205 · 4 commenti ·
-
agent:triaged bug bughunt pm:pipenv priority:p1
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
SocketDev/socket-patch#1608 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
adorsys/status-list-server#698 ·
I maintainer di solito rispondono entro 2 giorni
-
Expose the dot grid colourAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
nannou-org/egui_graph#92 ·
I maintainer di solito rispondono entro 1 giorno