diff --git a/aya-obj/src/btf/btf.rs b/aya-obj/src/btf/btf.rs index 4a65162b..e94b67be 100644 --- a/aya-obj/src/btf/btf.rs +++ b/aya-obj/src/btf/btf.rs @@ -712,10 +712,13 @@ impl BtfExt { // BTF.ext sections let mut header = std::mem::MaybeUninit::::zeroed(); // Safety: we have checked that len_to_read is less than - // size_of:: and less than data.len() - unsafe { std::ptr::copy(data.as_ptr(), header.as_mut_ptr() as *mut u8, len_to_read) }; - // Safety: the header began initialized to zero (and we rewrote some of its initla bytes) - unsafe { header.assume_init() } + // size_of:: and less than + // data.len(). Additionally, we know that the header has + // been initialized so it's safe to call for assume_init. + unsafe { + std::ptr::copy(data.as_ptr(), header.as_mut_ptr() as *mut u8, len_to_read); + header.assume_init() + } }; let btf_ext_header {