mirror of
https://github.com/nmap/nmap.git
synced 2026-06-09 17:22:26 +00:00
Don't double-count RTA_LENGTH in netlink messages.
For each rtattr we add to the netlink message, we were adding RTA_LENGTH(rtattr->rta_len) to the length of the netlink message. But rtattr->rta_len was already calculated as RTA_LENGTH of something, and doing RTA_LENGTH twice made the length 4 bytes longer than it should be. This caused a log in dmesg: netlink: 4 bytes leftover after parsing attributes. or netlink: 8 bytes leftover after parsing attributes. if there was an IPv6 scope ID (because that causes two rtattrs instead of one). The new code is consistent with the rtnetlink(3) man page, which does rta->rta_len = sizeof(unsigned int); req.n.nlmsg_len = NLMSG_ALIGN(req.n.nlmsg_len) + RTA_LENGTH(sizeof(unsigned int)); We do the equivalent rta->rta_len = sizeof(unsigned int); req.n.nlmsg_len = NLMSG_ALIGN(req.n.nlmsg_len) + rta->rta_len;
This commit is contained in:
parent
7205f00499
commit
a13313ad2f
1 changed files with 2 additions and 2 deletions
|
|
@ -2965,7 +2965,7 @@ static int route_dst_netlink(const struct sockaddr_storage *dst,
|
|||
rtattr->rta_len = RTA_LENGTH(addrlen);
|
||||
assert(RTA_OK(rtattr, len));
|
||||
memcpy(RTA_DATA(rtattr), addr, addrlen);
|
||||
nlmsg->nlmsg_len = NLMSG_ALIGN(nlmsg->nlmsg_len) + RTA_LENGTH(rtattr->rta_len);
|
||||
nlmsg->nlmsg_len = NLMSG_ALIGN(nlmsg->nlmsg_len) + rtattr->rta_len;
|
||||
|
||||
/* Specific interface (sin6_scope_id) requested? */
|
||||
if (ifindex > 0) {
|
||||
|
|
@ -2975,7 +2975,7 @@ static int route_dst_netlink(const struct sockaddr_storage *dst,
|
|||
rtattr->rta_len = RTA_LENGTH(sizeof(uint32_t));
|
||||
assert(RTA_OK(rtattr, len));
|
||||
*(uint32_t *) RTA_DATA(rtattr) = ifindex;
|
||||
nlmsg->nlmsg_len = NLMSG_ALIGN(nlmsg->nlmsg_len) + RTA_LENGTH(rtattr->rta_len);
|
||||
nlmsg->nlmsg_len = NLMSG_ALIGN(nlmsg->nlmsg_len) + rtattr->rta_len;
|
||||
}
|
||||
|
||||
iov.iov_base = nlmsg;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue