Skip to content
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

fix UB in Daemonize::privileged_action #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

27factorial
Copy link

Fixes UB in Daemonize::privileged_action by removing the transmute from Daemonize<T> to Daemonize<N>.

Transmuting between Daemonize<T> and Daemonize<N> is not guaranteed to be valid, as the transmute may temporarily put self.privileged_action into an invalid state.

The type layout of Daemonize<T> and Daemonize<N> are also not guaranteed to be equivalent, since the compiler may reorder the fields of different instances of the same generic type according to the Transmutes section of the Rustonomicon.

The solution used is to construct a Daemonize<N> manually and fill in the common fields from self, rather than transmuting and replacing just the privileged_action field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant