mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-01 06:00:12 +01:00
platform/netlink: ensure padding is zero in _nest_end()
nla_reserve() also ensures that the padding is zero, and only the padding. Thus, when we call nla_reserve(), we need to zero the padding ourselves.
This commit is contained in:
parent
78dfc56a74
commit
9ef02ef7d0
1 changed files with 5 additions and 1 deletions
|
|
@ -584,14 +584,18 @@ _nest_end(struct nl_msg *msg, struct nlattr *start, int keep_empty)
|
|||
|
||||
pad = NLMSG_ALIGN(msg->nm_nlh->nlmsg_len) - msg->nm_nlh->nlmsg_len;
|
||||
if (pad > 0) {
|
||||
void *p;
|
||||
|
||||
/*
|
||||
* Data inside attribute does not end at a alignment boundary.
|
||||
* Pad accordingly and account for the additional space in
|
||||
* the message. nlmsg_reserve() may never fail in this situation,
|
||||
* the allocate message buffer must be a multiple of NLMSG_ALIGNTO.
|
||||
*/
|
||||
if (!nlmsg_reserve(msg, pad, 0))
|
||||
p = nlmsg_reserve(msg, pad, 0);
|
||||
if (!p)
|
||||
g_return_val_if_reached(-NME_BUG);
|
||||
memset(p, 0, pad);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue