]> git.meshlink.io Git - meshlink/blobdiff - src/discovery.c
Fix uninitialized data being passed to sendmsg().
[meshlink] / src / discovery.c
index 948d786ed1af584797de1398a95ff6414d1118c3..4d05f7bc98e0373b4e2afc5685291c1025a639a4 100644 (file)
@@ -121,6 +121,8 @@ static void send_mdns_packet_ipv4(meshlink_handle_t *mesh, int fd, int index, co
                struct cmsghdr align;
        } u;
 
+       memset(&u, 0, sizeof(u));
+
        struct msghdr msg = {
                .msg_name = (struct sockaddr *) &dest->sa,
                .msg_namelen = SALEN(dest->sa),
@@ -130,7 +132,6 @@ static void send_mdns_packet_ipv4(meshlink_handle_t *mesh, int fd, int index, co
                .msg_controllen = sizeof(u.buf),
        };
 
-
        struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
        cmsg->cmsg_level = IPPROTO_IP;
        cmsg->cmsg_type = IP_PKTINFO;