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

Reading into uninitialized buffers #81

Open
sunfishcode opened this issue Oct 11, 2021 · 2 comments
Open

Reading into uninitialized buffers #81

sunfishcode opened this issue Oct 11, 2021 · 2 comments
Labels
enhancement New feature or request semver bump Issues that will require a semver-incompatible fix

Comments

@sunfishcode
Copy link
Member

Currently, read takes a &mut [u8]. That's fine for many use cases, but it does require the buffer to be initialized before calling read, so it's currently not possible to read directly into uninitialized memory.

For Mustang, the C read API takes a raw pointer which may be pointing to an uninitialized buffer. Currently mustang does slice::from_raw_parts_mut, however this has undefined behavior if the slice is uninitialized.

@sunfishcode sunfishcode added the semver bump Issues that will require a semver-incompatible fix label Apr 12, 2022
@sunfishcode
Copy link
Member Author

Mustang is now using temporary buffers to avoid having UB, but it could avoid this overhead if rustix had a way to read into uninitialized buffers directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request semver bump Issues that will require a semver-incompatible fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant