-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undocumented panics in std::process on unix for strings with interior nuls #30858
Comments
This also occurs with arg(), but env() in fact doesn't panic /at all/ for \0 (just silently gives you an environ you probably don't intend), because of accidents of implementation, which seems very sketchy. |
Given that it's possible to delay the conversion until spawning, I think that is the leas surprising thing to do. The env vars can be checked at that point as well. |
That would also be similar to what happens if you attempt to create a file (playground):
prints
|
I decided the behaviour with |
triage: I-nominated |
I've got a patch in the works for this. |
triage: P-medium The libs team discussed this in triage yesterday and the conclusion was that the defer-the-error strategy is fine for |
This reports an error at the point of calling `Command::spawn()` or one of its equivalents. Fixes rust-lang#30858 Fixes rust-lang#30862
All the strings are taken as
AsRef<OsStr>
and converted toCString
with unwrapping: https://github.com/rust-lang/rust/blob/master/src/libstd/sys/unix/process.rs#L83-L85An example for
Command::new
(playground):The panic should be documented, or the conversion unwrap should be delayed until a call to one of the methods that start the process so that the error can be returned in a
Result
.Version:
The text was updated successfully, but these errors were encountered: