mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 01:02:24 +00:00
Patch from Theo Markettos: apparently "BSD-derived IP stacks fall over when
trying to bind to the localhost interface with a sockaddr_in which has non-zero sin_zero fields." Zero sockaddr_in (and sockaddr_in6) before any use. [originally from svn r3793]
This commit is contained in:
parent
8472b1c8d7
commit
5e2a33caec
10
unix/uxnet.c
10
unix/uxnet.c
@ -434,6 +434,11 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
|
||||
else
|
||||
localport = 0; /* just use port 0 (ie kernel picks) */
|
||||
|
||||
/* BSD IP stacks need sockaddr_in zeroed before filling in */
|
||||
memset(&a,'\0',sizeof(struct sockaddr_in));
|
||||
#ifdef IPV6
|
||||
memset(&a6,'\0',sizeof(struct sockaddr_in6));
|
||||
#endif
|
||||
/* Loop round trying to bind */
|
||||
while (1) {
|
||||
int retcode;
|
||||
@ -574,7 +579,12 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only)
|
||||
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on));
|
||||
|
||||
/* BSD IP stacks need sockaddr_in zeroed before filling in */
|
||||
memset(&a,'\0',sizeof(struct sockaddr_in));
|
||||
#ifdef IPV6
|
||||
#if 0
|
||||
memset(&a6,'\0',sizeof(struct sockaddr_in6));
|
||||
#endif
|
||||
hints.ai_flags = AI_NUMERICHOST;
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user