From: Miroslav Lichvar Date: Thu, 16 Dec 2021 10:36:26 +0000 (+0100) Subject: cmdmon: fix transmit_reply() to not read uninitialized data X-Git-Tag: 4.2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5f2401421b59cbc50147fc30cd33233d7a388f2;p=thirdparty%2Fchrony.git cmdmon: fix transmit_reply() to not read uninitialized data In the FreeBSD-specific code checking for a bound IPv4 socket, make sure it is not a Unix domain address to avoid reading uninitialized IP-specific fields. This fixes an error reported by valgrind. --- diff --git a/cmdmon.c b/cmdmon.c index cd064707..89f5b95d 100644 --- a/cmdmon.c +++ b/cmdmon.c @@ -321,7 +321,8 @@ transmit_reply(int sock_fd, int request_length, SCK_Message *message) #if !defined(HAVE_IN_PKTINFO) && defined(IP_SENDSRCADDR) /* On FreeBSD a local IPv4 address cannot be specified on bound socket */ - if (message->local_addr.ip.family == IPADDR_INET4 && (sock_fd != sock_fd4 || bound_sock_fd4)) + if (message->addr_type == SCK_ADDR_IP && message->local_addr.ip.family == IPADDR_INET4 && + (sock_fd != sock_fd4 || bound_sock_fd4)) message->local_addr.ip.family = IPADDR_UNSPEC; #endif