X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/d2be8a4363cfeef2c8056f2ecd7aeb29b75e031f..f7aa4b367eaf2c1e928f97263bcf4da74680aff3:/unix/uxnet.c diff --git a/unix/uxnet.c b/unix/uxnet.c index fef4c43c..e9515241 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -572,17 +572,32 @@ static int try_connect(Actual_Socket sock) if (sock->oobinline) { int b = TRUE; - setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (void *) &b, sizeof(b)); + if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE, + (void *) &b, sizeof(b)) < 0) { + err = errno; + close(s); + goto ret; + } } if (sock->nodelay) { int b = TRUE; - setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (void *) &b, sizeof(b)); + if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, + (void *) &b, sizeof(b)) < 0) { + err = errno; + close(s); + goto ret; + } } if (sock->keepalive) { int b = TRUE; - setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (void *) &b, sizeof(b)); + if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, + (void *) &b, sizeof(b)) < 0) { + err = errno; + close(s); + goto ret; + } } /* @@ -835,7 +850,12 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i ret->oobinline = 0; - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on)); + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, + (const char *)&on, sizeof(on)) < 0) { + ret->error = strerror(errno); + close(s); + return (Socket) ret; + } retcode = -1; addr = NULL; addrlen = -1; /* placate optimiser */