On Thu, Feb 8, 2024 at 4:48 PM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote: > + /// Reads the entirety of the user slice, appending it to the end of the > + /// provided buffer. > + /// > + /// Fails with `EFAULT` if the read encounters a page fault. > + pub fn read_all(mut self, buf: &mut Vec<u8>) -> Result<()> { > + buf.try_reserve(self.length)?; > + > + // SAFETY: The call to `try_reserve` was successful, so the spare > + // capacity is at least `self.length` bytes long. > + unsafe { self.read_raw(buf.spare_capacity_mut().as_mut_ptr().cast(), self.length)? }; > + > + // SAFETY: Since the call to `read_raw` was successful, so the next > + // `len` bytes of the vector have been initialized. > + unsafe { buf.set_len(buf.len() + self.length) }; > + Ok(()) > + } There's a bug here, since read_raw changes self.length. It will be fixed in the next version. Alice