-
Notifications
You must be signed in to change notification settings - Fork 41
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
RawFdContainer
seems to be unsound
#363
Comments
Why? How can this lead to memory unsafety? This sounds weird and I have no idea on how an example could look like. From the docs:
Well, |
A
Something like this:
At this point, trying to do something with |
Random shower thought: A combination of This could also lead to a possibly slightly nicer API. Instead of requiring arguments of type |
I think it would be safe to provide traits to convert from individual types (such as So far, I created #386, which is still WIP |
Random data point: The scenario from #363 (comment) is possible without |
I would say that |
I'm closing this given the reasoning in nix-rust/nix#1225 |
Ah, thanks for opening that issue. That's indeed a helpful description. |
Possibly related: rust-lang/rust#72175 |
RawFdContainer
allows to wrap and close arbitrary file descriptors, which does not seem very safe. In fact, the standard library has this, where thefrom_raw_fd
method is unsafe.The solution would be to make
RawFdContainer::new
unsafe, removeimpl<T: IntoRawFd> From<T> for RawFdContainer
, and possibly implementstd::os::unix::io::FromRawFd
forRawFdContainer
.The text was updated successfully, but these errors were encountered: