Add an error check to every setsockopt call in uxnet.c.

[originally from svn r9939]
This commit is contained in:
Simon Tatham 2013-07-19 17:45:01 +00:00
Родитель 8966f7c1ea
Коммит 96f3589e16
1 изменённых файлов: 24 добавлений и 4 удалений

Просмотреть файл

@ -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 */