VDB
Sign up
—

RUSTSEC-2025-0105

Uninitialized memory exposure in create_ring_buffer

Details

The safe function `create_ring_buffer` allocates a buffer using `Vec::with_capacity` followed by `set_len`, creating a `Box<[T]>` containing uninitialized memory.

This leads to undefined behavior when functions like `write_slices` create typed slices (e.g., `&mut [bool]`) over the uninitialized memory, violating Rust's validity invariants. The issue has been confirmed using Miri.

Fixed in version 0.2.2 by using `resize_with` to properly initialize the buffer with `T::default()`, adding a `T: Default` bound to ensure sound initialization.

Are you affected?

Enter the version of the package you're using.

Affected packages

crates.io/direct_ring_buffer
Introduced in: 0.0.0-0Fixed in: 0.2.2

Upgrade direct_ring_buffer to 0.2.2 or newer (ecosystem crates.io).

References