aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.cpp
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2014-04-18 15:16:52 -0700
committerGregory Maxwell <greg@xiph.org>2014-04-18 15:16:52 -0700
commitfe451fe9441c9b23e4a13a1f00974e29f7a30462 (patch)
tree920b84767d1316e4f9bf364fd408266d22c8e74a /src/netbase.cpp
parent2f3308f2d2d46dd1f8f4a38a14e2cf1216b06afe (diff)
parent0bd05b53b155bc28b6e5dfd967cafaafb44a439f (diff)
Merge pull request #4037 from gmaxwell/fdleaks
Prevent socket leak in ThreadSocketHandler.
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r--src/netbase.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index d5b75d6afd..2b300e5dd3 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -293,8 +293,10 @@ bool static Socks5(string strDest, int port, SOCKET& hSocket)
case 0x03:
{
ret = recv(hSocket, pchRet3, 1, 0) != 1;
- if (ret)
+ if (ret) {
+ closesocket(hSocket);
return error("Error reading from proxy");
+ }
int nRecv = pchRet3[0];
ret = recv(hSocket, pchRet3, nRecv, 0) != nRecv;
break;
@@ -501,6 +503,7 @@ bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout)
return false;
break;
default:
+ closesocket(hSocket);
return false;
}
@@ -532,7 +535,9 @@ bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest
switch(nameproxy.second) {
default:
- case 4: return false;
+ case 4:
+ closesocket(hSocket);
+ return false;
case 5:
if (!Socks5(strDest, port, hSocket))
return false;