Reading into uninitialized buffers #81
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or requestsemver bumpIssues that will require a semver-incompatible fixIssues that will require a semver-incompatible fix
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestsemver bumpIssues that will require a semver-incompatible fixIssues that will require a semver-incompatible fix
Activity
sunfishcode commentedon Apr 30, 2022
This issue affects Rust more broadly; here are some links:
sunfishcode commentedon Oct 7, 2022
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.
sunfishcode commentedon Mar 6, 2025
This is now implemented in rustix 1.0.0.