Skip to content

Commit 5edc49e

Browse files
authored
Fix crash during copy to dst (#333)
dest_slice will always be the max size and src_slice is a subset of this length. Must not copy beyond the src_slice.len otherwise will access invalid data and crash.
1 parent aae08b6 commit 5edc49e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

espi-service/src/espi_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ pub async fn espi_service(mut espi: espi::Espi<'static>, memory_map_buffer: &'st
218218

219219
match result {
220220
Ok(dest_slice) => {
221-
dest_slice.copy_from_slice(src_slice);
221+
dest_slice[..src_slice.len()].copy_from_slice(src_slice);
222222
}
223223
Err(_e) => {
224224
#[cfg(feature = "defmt")]

0 commit comments

Comments
 (0)