sys_util: netlink: fix wrong setting of the netlink msg data end boundary

The netlink data end boundary should be actually set by msg_len. The
previous calculation of data_end and its usage was probably confused with
data size.

This bug prevented access to the entire netlink's message data.

BUG=b:197247746
TEST=Build and print the `data` when netlink message arrives.

Change-Id: I601bcfee9132649f48f774e23426281ba1e88fde
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3375544
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Grzegorz Jaszczyk 2022-01-07 23:58:53 +00:00 committed by Commit Bot
parent 477459aea6
commit 2c0459db66

View file

@ -56,8 +56,7 @@ impl<'a> Iterator for NetlinkMessageIter<'a> {
// NLMSG_DATA
let data_start = HDR_SIZE;
let data_end = msg_len - data_start;
let data = &self.data[data_start..data_end];
let data = &self.data[data_start..msg_len];
// NLMSG_NEXT
let align_to = std::mem::align_of::<NlMsgHdr>();