From a11c0f3b8a605bafacead47de489ab391122e8b4 Mon Sep 17 00:00:00 2001 From: Rafael Ortiz Date: Mon, 21 Jun 2021 10:34:18 -0400 Subject: [PATCH] add a warning --- aya/src/obj/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aya/src/obj/mod.rs b/aya/src/obj/mod.rs index 5c714bb4..2579dca7 100644 --- a/aya/src/obj/mod.rs +++ b/aya/src/obj/mod.rs @@ -521,7 +521,9 @@ fn parse_map_def(name: &str, data: &[u8]) -> Result { unsafe { // std::ptr::copy is const, we can't use it because data.len() isn't known at - // compile time + // compile time, this is only safe because we've asserted that data.len() + // must be <= mem::size_of::(), if you change that check, then + // you must change this copy let mut p = data.as_ptr(); let mut q = &mut map_def as *mut bpf_map_def as *mut u8; for _ in 0..=data.len() {