zero out socket structures before bind.

This commit is contained in:
christos 2018-02-25 19:22:41 +00:00
parent 64900a4c4b
commit 58300083f7

View File

@ -745,6 +745,10 @@ mDNSlocal int SetupSocket(struct sockaddr *intfAddr, mDNSIPPort port, int interf
// And start listening for packets
if (err == 0)
{
mDNSPlatformMemZero(&bindAddr, sizeof(bindAddr));
#ifndef NOT_HAVE_SA_LEN
bindAddr.sin_len = sizeof(bindAddr);
#endif
bindAddr.sin_family = AF_INET;
bindAddr.sin_port = port.NotAnInteger;
bindAddr.sin_addr.s_addr = INADDR_ANY; // Want to receive multicasts AND unicasts on this socket
@ -1054,6 +1058,9 @@ mDNSlocal mStatus OpenIfNotifySocket(int *pFD)
/* Subscribe the socket to Link & IP addr notifications. */
mDNSPlatformMemZero(&snl, sizeof snl);
#ifndef NOT_HAVE_SA_LEN
snl.nl_len = sizeof(snl);
#endif
snl.nl_family = AF_NETLINK;
snl.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR;
ret = bind(sock, (struct sockaddr *) &snl, sizeof snl);
@ -1266,6 +1273,11 @@ mDNSlocal mDNSBool mDNSPlatformInit_CanReceiveUnicast(void)
int err;
int s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
struct sockaddr_in s5353;
mDNSPlatformMemZero(&s5353, sizeof(s5353));
#ifndef NOT_HAVE_SA_LEN
s5353.sin_len = sizeof(s5353);
#endif
s5353.sin_family = AF_INET;
s5353.sin_port = MulticastDNSPort.NotAnInteger;
s5353.sin_addr.s_addr = 0;