X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=unix%2Fuxnet.c;h=e409315a66a8b808d6463e202b0423f09554a48e;hb=89da2ddf564a93414ee9ab2df3f053608094e417;hp=1fe78436115878ce98174c6d5d9de8e158db4208;hpb=8da4fa506389910599c59b87ba1b799efd6d3ae1;p=PuTTY.git diff --git a/unix/uxnet.c b/unix/uxnet.c index 1fe78436..e409315a 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -126,9 +126,12 @@ struct SockAddr_tag { (addr)->superfamily == UNIX ? AF_UNIX : \ (step).ai ? (step).ai->ai_family : AF_INET) #else +/* Here we gratuitously reference 'step' to avoid gcc warnings about + * 'set but not used' when compiling -DNO_IPV6 */ #define SOCKADDR_FAMILY(addr, step) \ ((addr)->superfamily == UNRESOLVED ? AF_UNSPEC : \ - (addr)->superfamily == UNIX ? AF_UNIX : AF_INET) + (addr)->superfamily == UNIX ? AF_UNIX : \ + (step).curraddr ? AF_INET : AF_INET) #endif /* @@ -773,11 +776,12 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline, return (Socket) ret; } -Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, int orig_address_family) +Socket sk_newlistener(const char *srcaddr, int port, Plug plug, + int local_host_only, int orig_address_family) { int s; #ifndef NO_IPV6 - struct addrinfo hints, *ai; + struct addrinfo hints, *ai = NULL; char portstr[6]; #endif union sockaddr_union u; @@ -923,6 +927,12 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i } retcode = bind(s, &addr->sa, addrlen); + +#ifndef NO_IPV6 + if (ai) + freeaddrinfo(ai); +#endif + if (retcode < 0) { close(s); ret->error = strerror(errno);