]> git.meshlink.io Git - meshlink/commitdiff
Fix uninitialized data being passed to sendmsg().
authorGuus Sliepen <guus@meshlink.io>
Tue, 4 May 2021 19:53:27 +0000 (21:53 +0200)
committerGuus Sliepen <guus@meshlink.io>
Tue, 4 May 2021 19:54:52 +0000 (21:54 +0200)
Found by Valgrind.

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;