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

Multiheader::preallocate causes an uninitialized value to be dereferenced #1990

Open
djkoloski opened this issue Jan 30, 2023 · 0 comments · May be fixed by #1992
Open

Multiheader::preallocate causes an uninitialized value to be dereferenced #1990

djkoloski opened this issue Jan 30, 2023 · 0 comments · May be fixed by #1992

Comments

@djkoloski
Copy link
Contributor

In src/sys/socket/mod.rs, Multiheader::preallocate allocates a vec or MaybeUninit::uninit() and then passes each address.as_mut_ptr() to pack_mhdr_to_receive. pack_mhdr_to_receive in turn performs (*address).as_mut_ptr(), which results in undefined behavior.

To support this desired behavior SockaddrLikePriv must change the signature of as_mut_ptr to fn(*mut Self) -> *mut libc::sockaddr and use ptr::addr_of_mut! to access fields in implementations. It does not appear that performing *mut S as *mut libc::sockaddr is possible because () implements SockaddrLike but returns null_mut() from its SockaddrLikePriv implementation.

@djkoloski djkoloski linked a pull request Jan 31, 2023 that will close this issue
@Jan561 Jan561 mentioned this issue Nov 23, 2023
3 tasks
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 a pull request may close this issue.

1 participant