-
Notifications
You must be signed in to change notification settings - Fork 691
CmsgSpace::new unsafely creates uninitialized, arbitrary types #994
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
Comments
Good catch. Unfortunately, we can't require |
Nevermind. I'm going to eliminate CmsgSpace instead. |
asomers
added a commit
to asomers/nix
that referenced
this issue
Jan 30, 2019
CmsgSpace had three problems: 1) It would oversize buffers that expect multiple control messages 2) It didn't use the libc CMSG_SPACE(3) macro, so it might actually undersize a buffer for a single control message. 3) It could do bad things on drop, if you instantiate it with a type that implements Drop (which none of the currently supported ControlMessage types do). Fixes nix-rust#994
Merged
asomers
added a commit
to asomers/nix
that referenced
this issue
Jan 31, 2019
CmsgSpace had three problems: 1) It would oversize buffers that expect multiple control messages 2) It didn't use the libc CMSG_SPACE(3) macro, so it might actually undersize a buffer for a single control message. 3) It could do bad things on drop, if you instantiate it with a type that implements Drop (which none of the currently supported ControlMessage types do). Fixes nix-rust#994
asomers
added a commit
to asomers/nix
that referenced
this issue
Feb 12, 2019
CmsgSpace had three problems: 1) It would oversize buffers that expect multiple control messages 2) It didn't use the libc CMSG_SPACE(3) macro, so it might actually undersize a buffer for a single control message. 3) It could do bad things on drop, if you instantiate it with a type that implements Drop (which none of the currently supported ControlMessage types do). Fixes nix-rust#994
asomers
added a commit
to asomers/nix
that referenced
this issue
Feb 14, 2019
CmsgSpace had three problems: 1) It would oversize buffers that expect multiple control messages 2) It didn't use the libc CMSG_SPACE(3) macro, so it might actually undersize a buffer for a single control message. 3) It could do bad things on drop, if you instantiate it with a type that implements Drop (which none of the currently supported ControlMessage types do). Fixes nix-rust#994
vdagonneau
pushed a commit
to vdagonneau/nix
that referenced
this issue
Feb 20, 2019
CmsgSpace had three problems: 1) It would oversize buffers that expect multiple control messages 2) It didn't use the libc CMSG_SPACE(3) macro, so it might actually undersize a buffer for a single control message. 3) It could do bad things on drop, if you instantiate it with a type that implements Drop (which none of the currently supported ControlMessage types do). Fixes nix-rust#994
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Even though the uninitialized field is private, it still gets dropped. For example
nix::sys::socket::CmsgSpace::<String>::new();
easily causes a segfault.The field should probably be
ManuallyDrop<T>
, or there should be aT: Copy
bound.The text was updated successfully, but these errors were encountered: