diff --git a/src/txbuf.rs b/src/txbuf.rs index ef718d7..b18c80f 100644 --- a/src/txbuf.rs +++ b/src/txbuf.rs @@ -2,7 +2,7 @@ use std::{io::Write, num::Wrapping}; -use vm_memory::{bitmap::BitmapSlice, VolatileSlice}; +use vm_memory::{bitmap::BitmapSlice, VolatileMemory, VolatileSlice}; use crate::vhu_vsock::{Error, Result}; @@ -55,7 +55,11 @@ impl LocalTxBuf { // Check if there is more data to be wrapped around if len < data_buf.len() { let remain_txbuf = &mut self.buf[..(data_buf.len() - len)]; - data_buf.copy_to(remain_txbuf); + // SAFETY ok to unwrap because len < data_buf.len() + data_buf + .get_slice(len, data_buf.len() - len) + .unwrap() + .copy_to(remain_txbuf); } // Increment tail by the amount of data that has been added to the buffer