From 932ce5bb0058ad5e757bd83476e297404f1bcb8b Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 4 May 2021 21:53:27 +0200 Subject: [PATCH] Fix uninitialized data being passed to sendmsg(). Found by Valgrind. --- src/discovery.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/discovery.c b/src/discovery.c index 948d786e..4d05f7bc 100644 --- a/src/discovery.c +++ b/src/discovery.c @@ -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; -- 2.39.5