diff --git a/aya/src/sys/netlink.rs b/aya/src/sys/netlink.rs index 033d58d7..36c508de 100644 --- a/aya/src/sys/netlink.rs +++ b/aya/src/sys/netlink.rs @@ -438,13 +438,15 @@ fn write_attr_header(buf: &mut [u8], offset: usize, attr: nlattr) -> Result Result { - if offset + value.len() > buf.len() { + let align_len = align_to(value.len(), NLA_ALIGNTO as usize); + if offset + align_len > buf.len() { return Err(io::Error::new(io::ErrorKind::Other, "no space left")); } buf[offset..offset + value.len()].copy_from_slice(value); - Ok(value.len()) + Ok(align_len) +} }