mirror of
https://github.com/nmap/nmap.git
synced 2025-12-18 13:39:02 +00:00
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;