diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-03-10 06:46:01 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-03-10 06:46:01 -0800 |
commit | 8bc6ba624272e9df414358195025cd696c491ad9 (patch) | |
tree | 86008aa5793ec7b964d7d3947e0b223875c1db63 /socket.c | |
parent | cf0d9e5d49ca21fc45cf222b53e5a9124ce8e07e (diff) | |
download | txr-8bc6ba624272e9df414358195025cd696c491ad9.tar.gz txr-8bc6ba624272e9df414358195025cd696c491ad9.tar.bz2 txr-8bc6ba624272e9df414358195025cd696c491ad9.zip |
Mac OS X: must clear sockaddr in order to bind.
Undocumented members in struct sockaddr_in, and possibly
sockaddr_in6 also, must be cleared to all zero bits, otherwise
bind fails for the loopback address, even if the relevant
addressing members are correctly set.
* socket.c (sockaddr_in): memset the IPv4 or IPv6 address
to zero before filing it.
Diffstat (limited to 'socket.c')
-rw-r--r-- | socket.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -221,6 +221,7 @@ static void sockaddr_in(val sockaddr, val family, struct sockaddr_in *sa = coerce(struct sockaddr_in *, buf); if (family != num_fast(AF_INET)) addr_mismatch(sockaddr, family); + memset(sa, 0, sizeof *sa); sa->sin_family = AF_INET; ipv4_addr_from_num(&sa->sin_addr, addr); sa->sin_port = ntohs(c_num(port)); @@ -233,6 +234,7 @@ static void sockaddr_in(val sockaddr, val family, struct sockaddr_in6 *sa = coerce(struct sockaddr_in6 *, buf); if (family != num_fast(AF_INET6)) addr_mismatch(sockaddr, family); + memset(sa, 0, sizeof *sa); sa->sin6_family = AF_INET6; ipv6_addr_from_num(&sa->sin6_addr, addr); ipv6_flow_info_from_num(sa, flow); |