X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/1cfc764f7b2e6d6c68bb2476ee85371783a0db5e..c24e27c631bae3139724e5a0951a12a956353bca:/unix/uxnet.c diff --git a/unix/uxnet.c b/unix/uxnet.c index c624e0d4..d01a44d9 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -22,6 +22,11 @@ #include "network.h" #include "tree234.h" +/* Solaris needs for SIOCATMARK. */ +#ifndef SIOCATMARK +#include +#endif + #ifndef X11_UNIX_PATH # define X11_UNIX_PATH "/tmp/.X11-unix/X" #endif @@ -231,7 +236,7 @@ SockAddr sk_nonamelookup(const char *host) static int sk_nextaddr(SockAddr addr) { #ifndef NO_IPV6 - if (addr->ai->ai_next) { + if (addr->ai && addr->ai->ai_next) { addr->ai = addr->ai->ai_next; addr->family = addr->ai->ai_family; return TRUE; @@ -576,6 +581,7 @@ static int try_connect(Actual_Socket sock) default: assert(0 && "unknown address family"); + exit(1); /* XXX: GCC doesn't understand assert() on some systems. */ } fl = fcntl(s, F_GETFL); @@ -685,7 +691,10 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i * into local reality. */ address_family = (address_family == ADDRTYPE_IPV4 ? AF_INET : - address_family == ADDRTYPE_IPV6 ? AF_INET6 : AF_UNSPEC); +#ifndef NO_IPV6 + address_family == ADDRTYPE_IPV6 ? AF_INET6 : +#endif + AF_UNSPEC); #ifndef NO_IPV6 /* Let's default to IPv6. @@ -701,11 +710,13 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i */ s = socket(address_family, SOCK_STREAM, 0); +#ifndef NO_IPV6 /* If the host doesn't support IPv6 try fallback to IPv4. */ if (s < 0 && address_family == AF_INET6) { address_family = AF_INET; s = socket(address_family, SOCK_STREAM, 0); } +#endif if (s < 0) { ret->error = strerror(errno); @@ -744,9 +755,8 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i if (a.sin_addr.s_addr != (in_addr_t)(-1)) { /* Override localhost_only with specified listen addr. */ ret->localhost_only = ipv4_is_loopback(a.sin_addr); - got_addr = 1; } - addr = (struct sockaddr *)a; + addr = (struct sockaddr *)&a; addrlen = sizeof(a); retcode = 0; #endif @@ -812,16 +822,6 @@ static void sk_tcp_close(Socket sock) sfree(s); } -#define PUT_32BIT_MSB_FIRST(cp, value) ( \ - (cp)[0] = (char)((value) >> 24), \ - (cp)[1] = (char)((value) >> 16), \ - (cp)[2] = (char)((value) >> 8), \ - (cp)[3] = (char)(value) ) - -#define PUT_16BIT_MSB_FIRST(cp, value) ( \ - (cp)[0] = (char)((value) >> 8), \ - (cp)[1] = (char)(value) ) - void *sk_getxdmdata(void *sock, int *lenp) { Actual_Socket s = (Actual_Socket) sock; @@ -911,11 +911,9 @@ void try_send(Actual_Socket s) */ s->writable = FALSE; return; - } else if (nsent == 0 || - err == ECONNABORTED || err == ECONNRESET) { + } else { /* - * If send() returns CONNABORTED or CONNRESET, we - * unfortunately can't just call plug_closing(), + * We unfortunately can't just call plug_closing(), * because it's quite likely that we're currently * _in_ a call from the code we'd be calling back * to, so we'd have to make half the SSH code @@ -925,11 +923,6 @@ void try_send(Actual_Socket s) */ s->pending_error = err; return; - } else { - /* We're inside the Unix frontend here, so we know - * that the frontend handle is unnecessary. */ - logevent(NULL, strerror(err)); - fatalbox("%s", strerror(err)); } } else { if (s->sending_oob) { @@ -1024,12 +1017,9 @@ static int net_select_result(int fd, int event) ret = recv(s->s, buf, sizeof(buf), MSG_OOB); noise_ultralight(ret); if (ret <= 0) { - const char *str = (ret == 0 ? "Internal networking trouble" : - strerror(errno)); - /* We're inside the Unix frontend here, so we know - * that the frontend handle is unnecessary. */ - logevent(NULL, str); - fatalbox("%s", str); + return plug_closing(s->plug, + ret == 0 ? "Internal networking trouble" : + strerror(errno), errno, 0); } else { /* * Receiving actual data on a socket means we can @@ -1292,9 +1282,10 @@ SockAddr platform_get_x11_unix_address(int displaynum, char **canonicalname) else *canonicalname = dupstr(ret->hostname); #ifndef NO_IPV6 - ret->ais = NULL; + ret->ai = ret->ais = NULL; #else ret->addresses = NULL; + ret->curraddr = ret->naddresses = 0; #endif return ret; }