kernel-netlink: Align concatenated Netlink responses
The code to support parallel Netlink queries (commit 3c7193f) made use
of nlmsg_len member from struct nlmsghdr to allocate and copy the
responses. Since NLMSG_NEXT is later used to parse these responses, they
must be aligned, or the results are undefined.
Signed-off-by: Thomas Egerer <[email protected]>
This commit is contained in:
committed by
Tobias Brunner
parent
2ff4983adc
commit
5100a3ed7d
@@ -381,7 +381,7 @@ static status_t send_once(private_netlink_socket_t *this, struct nlmsghdr *in,
|
|||||||
for (i = 0, *out_len = 0; i < array_count(entry->hdrs); i++)
|
for (i = 0, *out_len = 0; i < array_count(entry->hdrs); i++)
|
||||||
{
|
{
|
||||||
array_get(entry->hdrs, i, &hdr);
|
array_get(entry->hdrs, i, &hdr);
|
||||||
*out_len += hdr->nlmsg_len;
|
*out_len += NLMSG_ALIGN(hdr->nlmsg_len);
|
||||||
}
|
}
|
||||||
ptr = malloc(*out_len);
|
ptr = malloc(*out_len);
|
||||||
*out = (struct nlmsghdr*)ptr;
|
*out = (struct nlmsghdr*)ptr;
|
||||||
@@ -394,7 +394,7 @@ static status_t send_once(private_netlink_socket_t *this, struct nlmsghdr *in,
|
|||||||
hdr->nlmsg_seq, hdr, hdr->nlmsg_len);
|
hdr->nlmsg_seq, hdr, hdr->nlmsg_len);
|
||||||
}
|
}
|
||||||
memcpy(ptr, hdr, hdr->nlmsg_len);
|
memcpy(ptr, hdr, hdr->nlmsg_len);
|
||||||
ptr += hdr->nlmsg_len;
|
ptr += NLMSG_ALIGN(hdr->nlmsg_len);
|
||||||
free(hdr);
|
free(hdr);
|
||||||
}
|
}
|
||||||
destroy_entry(entry);
|
destroy_entry(entry);
|
||||||
|
|||||||
Reference in New Issue
Block a user