tests: Fix UB in AF_XDP test

pull/846/head
arctic-alpaca 1 year ago
parent 5075adc01d
commit cad03f01f5
No known key found for this signature in database
GPG Key ID: 5556CF6C310CFACD

@ -32,9 +32,9 @@ fn af_xdp() {
struct PacketMap(MaybeUninit<[u8; 4096]>);
// Safety: don't access alloc down the line.
let mut alloc = Box::new(PacketMap(MaybeUninit::uninit()));
let mut alloc = Box::new(PacketMap(MaybeUninit::zeroed()));
let umem = {
// Safety: this is a shared buffer between the kernel and us, uninitialized memory is valid.
// Safety: Zeroed memory is valid for u8 arrays.
let mem = unsafe { alloc.0.assume_init_mut() }.as_mut().into();
// Safety: we cannot access `mem` further down the line because it falls out of scope.
unsafe { Umem::new(UmemConfig::default(), mem).unwrap() }

Loading…
Cancel
Save