|
@@ -319,11 +319,21 @@ void sk_init(void)
|
|
GET_WINDOWS_FUNCTION(winsock_module, WSAStartup);
|
|
GET_WINDOWS_FUNCTION(winsock_module, WSAStartup);
|
|
GET_WINDOWS_FUNCTION(winsock_module, WSACleanup);
|
|
GET_WINDOWS_FUNCTION(winsock_module, WSACleanup);
|
|
GET_WINDOWS_FUNCTION(winsock_module, closesocket);
|
|
GET_WINDOWS_FUNCTION(winsock_module, closesocket);
|
|
|
|
+#ifndef COVERITY
|
|
GET_WINDOWS_FUNCTION(winsock_module, ntohl);
|
|
GET_WINDOWS_FUNCTION(winsock_module, ntohl);
|
|
GET_WINDOWS_FUNCTION(winsock_module, htonl);
|
|
GET_WINDOWS_FUNCTION(winsock_module, htonl);
|
|
GET_WINDOWS_FUNCTION(winsock_module, htons);
|
|
GET_WINDOWS_FUNCTION(winsock_module, htons);
|
|
GET_WINDOWS_FUNCTION(winsock_module, ntohs);
|
|
GET_WINDOWS_FUNCTION(winsock_module, ntohs);
|
|
GET_WINDOWS_FUNCTION(winsock_module, gethostname);
|
|
GET_WINDOWS_FUNCTION(winsock_module, gethostname);
|
|
|
|
+#else
|
|
|
|
+ /* The toolchain I use for Windows Coverity builds doesn't know
|
|
|
|
+ * the type signatures of these */
|
|
|
|
+ GET_WINDOWS_FUNCTION_NO_TYPECHECK(winsock_module, ntohl);
|
|
|
|
+ GET_WINDOWS_FUNCTION_NO_TYPECHECK(winsock_module, htonl);
|
|
|
|
+ GET_WINDOWS_FUNCTION_NO_TYPECHECK(winsock_module, htons);
|
|
|
|
+ GET_WINDOWS_FUNCTION_NO_TYPECHECK(winsock_module, ntohs);
|
|
|
|
+ GET_WINDOWS_FUNCTION_NO_TYPECHECK(winsock_module, gethostname);
|
|
|
|
+#endif
|
|
GET_WINDOWS_FUNCTION(winsock_module, gethostbyname);
|
|
GET_WINDOWS_FUNCTION(winsock_module, gethostbyname);
|
|
GET_WINDOWS_FUNCTION(winsock_module, getservbyname);
|
|
GET_WINDOWS_FUNCTION(winsock_module, getservbyname);
|
|
GET_WINDOWS_FUNCTION(winsock_module, inet_addr);
|
|
GET_WINDOWS_FUNCTION(winsock_module, inet_addr);
|
|
@@ -567,7 +577,7 @@ SockAddr sk_namelookup(const char *host, char **canonicalname,
|
|
|
|
|
|
if ((a = p_inet_addr(host)) == (unsigned long) INADDR_NONE) {
|
|
if ((a = p_inet_addr(host)) == (unsigned long) INADDR_NONE) {
|
|
struct hostent *h = NULL;
|
|
struct hostent *h = NULL;
|
|
- int err;
|
|
|
|
|
|
+ int err = 0;
|
|
#ifndef NO_IPV6
|
|
#ifndef NO_IPV6
|
|
/*
|
|
/*
|
|
* Use getaddrinfo when it's available
|
|
* Use getaddrinfo when it's available
|
|
@@ -1742,9 +1752,9 @@ static void sk_tcp_write_eof(Socket sock)
|
|
try_send(s);
|
|
try_send(s);
|
|
}
|
|
}
|
|
|
|
|
|
-int select_result(WPARAM wParam, LPARAM lParam)
|
|
|
|
|
|
+void select_result(WPARAM wParam, LPARAM lParam)
|
|
{
|
|
{
|
|
- int ret, open;
|
|
|
|
|
|
+ int ret;
|
|
DWORD err;
|
|
DWORD err;
|
|
char buf[20480]; /* nice big buffer for plenty of speed */
|
|
char buf[20480]; /* nice big buffer for plenty of speed */
|
|
Actual_Socket s;
|
|
Actual_Socket s;
|
|
@@ -1753,11 +1763,11 @@ int select_result(WPARAM wParam, LPARAM lParam)
|
|
/* wParam is the socket itself */
|
|
/* wParam is the socket itself */
|
|
|
|
|
|
if (wParam == 0)
|
|
if (wParam == 0)
|
|
- return 1; /* boggle */
|
|
|
|
|
|
+ return; /* boggle */
|
|
|
|
|
|
s = find234(sktree, (void *) wParam, cmpforsearch);
|
|
s = find234(sktree, (void *) wParam, cmpforsearch);
|
|
if (!s)
|
|
if (!s)
|
|
- return 1; /* boggle */
|
|
|
|
|
|
+ return; /* boggle */
|
|
|
|
|
|
if ((err = WSAGETSELECTERROR(lParam)) != 0) {
|
|
if ((err = WSAGETSELECTERROR(lParam)) != 0) {
|
|
/*
|
|
/*
|
|
@@ -1779,10 +1789,9 @@ int select_result(WPARAM wParam, LPARAM lParam)
|
|
}
|
|
}
|
|
if (err != 0)
|
|
if (err != 0)
|
|
{
|
|
{
|
|
- return plug_closing(s->plug, winsock_error_string(err), err, 0);
|
|
|
|
|
|
+ plug_closing(s->plug, winsock_error_string(err), err, 0);
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- else
|
|
|
|
- return 1;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
noise_ultralight(lParam);
|
|
noise_ultralight(lParam);
|
|
@@ -1835,12 +1844,11 @@ int select_result(WPARAM wParam, LPARAM lParam)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
- return plug_closing(s->plug, winsock_error_string(err), err,
|
|
|
|
- 0);
|
|
|
|
|
|
+ plug_closing(s->plug, winsock_error_string(err), err, 0);
|
|
} else if (0 == ret) {
|
|
} else if (0 == ret) {
|
|
- return plug_closing(s->plug, NULL, 0, 0);
|
|
|
|
|
|
+ plug_closing(s->plug, NULL, 0, 0);
|
|
} else {
|
|
} else {
|
|
- return plug_receive(s->plug, atmark ? 0 : 1, buf, ret);
|
|
|
|
|
|
+ plug_receive(s->plug, atmark ? 0 : 1, buf, ret);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case FD_OOB:
|
|
case FD_OOB:
|
|
@@ -1860,7 +1868,7 @@ int select_result(WPARAM wParam, LPARAM lParam)
|
|
logevent(NULL, str);
|
|
logevent(NULL, str);
|
|
fatalbox("%s", str);
|
|
fatalbox("%s", str);
|
|
} else {
|
|
} else {
|
|
- return plug_receive(s->plug, 2, buf, ret);
|
|
|
|
|
|
+ plug_receive(s->plug, 2, buf, ret);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case FD_WRITE:
|
|
case FD_WRITE:
|
|
@@ -1876,25 +1884,23 @@ int select_result(WPARAM wParam, LPARAM lParam)
|
|
break;
|
|
break;
|
|
case FD_CLOSE:
|
|
case FD_CLOSE:
|
|
/* Signal a close on the socket. First read any outstanding data. */
|
|
/* Signal a close on the socket. First read any outstanding data. */
|
|
- open = 1;
|
|
|
|
do {
|
|
do {
|
|
ret = p_recv(s->s, buf, sizeof(buf), 0);
|
|
ret = p_recv(s->s, buf, sizeof(buf), 0);
|
|
if (ret < 0) {
|
|
if (ret < 0) {
|
|
err = p_WSAGetLastError();
|
|
err = p_WSAGetLastError();
|
|
if (err == WSAEWOULDBLOCK)
|
|
if (err == WSAEWOULDBLOCK)
|
|
break;
|
|
break;
|
|
- return plug_closing(s->plug, winsock_error_string(err),
|
|
|
|
- err, 0);
|
|
|
|
|
|
+ plug_closing(s->plug, winsock_error_string(err), err, 0);
|
|
} else {
|
|
} else {
|
|
if (ret)
|
|
if (ret)
|
|
- open &= plug_receive(s->plug, 0, buf, ret);
|
|
|
|
|
|
+ plug_receive(s->plug, 0, buf, ret);
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- open &= plug_closing(s->plug, NULL, 0, 0);
|
|
|
|
|
|
+ plug_closing(s->plug, NULL, 0, 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} while (ret > 0);
|
|
} while (ret > 0);
|
|
- return open;
|
|
|
|
|
|
+ return;
|
|
case FD_ACCEPT:
|
|
case FD_ACCEPT:
|
|
{
|
|
{
|
|
#ifdef NO_IPV6
|
|
#ifdef NO_IPV6
|
|
@@ -1932,8 +1938,6 @@ int select_result(WPARAM wParam, LPARAM lParam)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- return 1;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|