From: Lennart Poettering Date: Mon, 24 Apr 2006 13:39:50 +0000 (+0000) Subject: make the construction of the ancillary data for sendmsg() a bit more robust. (see... X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=47e8c59490722ddef0de8b7964a50abf7d226989;p=catta make the construction of the ancillary data for sendmsg() a bit more robust. (see #32) git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1199 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/avahi-core/socket.c b/avahi-core/socket.c index 453ce54..0eb0374 100644 --- a/avahi-core/socket.c +++ b/avahi-core/socket.c @@ -499,7 +499,10 @@ int avahi_send_dns_packet_ipv4(int fd, AvahiIfIndex interface, AvahiDnsPacket *p struct in_pktinfo *pkti; memset(cmsg_data, 0, sizeof(cmsg_data)); - cmsg = (struct cmsghdr*) cmsg_data; + msg.msg_control = cmsg_data; + msg.msg_controllen = sizeof(cmsg_data); + + cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo)); cmsg->cmsg_level = IPPROTO_IP; cmsg->cmsg_type = IP_PKTINFO; @@ -512,8 +515,7 @@ int avahi_send_dns_packet_ipv4(int fd, AvahiIfIndex interface, AvahiDnsPacket *p if (src_address) pkti->ipi_spec_dst.s_addr = src_address->address; - msg.msg_control = cmsg_data; - msg.msg_controllen = CMSG_SPACE(sizeof(struct in_pktinfo)); + msg.msg_controllen = cmsg->cmsg_len; } #elif defined(IP_SENDSRCADDR) if (src_address) {