IP_PKTINFO: set msg_controllen upon output

This fixes a bug where when writing IP_PKTINFO to msg_control, the
msg_controllen field was not updated with the length written

This bug is exposed by applications that provide a msg_control buffer large
enough for multiple control messages.  Then when calling CMSG_NXTHDR, it
returned a next cmsg pointer even though was no additional message
This commit is contained in:
Joel Cunningham 2017-07-20 12:00:57 -05:00
parent 5cd475d91b
commit 99e1f37b82

View File

@ -1088,6 +1088,7 @@ lwip_recvfrom_udp_raw(struct lwip_sock *sock, int flags, struct msghdr *msg, u16
chdr->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
pkti->ipi_ifindex = buf->p->if_idx;
inet_addr_from_ip4addr(&pkti->ipi_addr, ip_2_ip4(netbuf_destaddr(buf)));
msg->msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo));
wrote_msg = 1;
} else {
msg->msg_flags |= MSG_CTRUNC;