]> git.meshlink.io Git - catta/commitdiff
make the construction of the ancillary data for sendmsg() a bit more robust. (see...
authorLennart Poettering <lennart@poettering.net>
Mon, 24 Apr 2006 13:39:50 +0000 (13:39 +0000)
committerLennart Poettering <lennart@poettering.net>
Mon, 24 Apr 2006 13:39:50 +0000 (13:39 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1199 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-core/socket.c

index 453ce54d996f0a0d5c5579eebaa7e38a91e1e373..0eb0374d065c6c2c6f75b8dda7e2239f927065f9 100644 (file)
@@ -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) {