summaryrefslogtreecommitdiff
path: root/src/modules/netlib
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-12-21 21:08:28 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-12-21 21:08:28 +0000
commitaba0e4dc3f85c83fa3beb0d79d494857d83e25bf (patch)
treec9fab8bbe91a86dadc5c79114f6b9e0878311a78 /src/modules/netlib
parent096a1529d9d3a3fd7a1c5a05dae18a9e89678566 (diff)
SSL context double shutdown prevention
git-svn-id: http://svn.miranda-ng.org/main/trunk@11567 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/netlib')
-rw-r--r--src/modules/netlib/netlib.cpp22
-rw-r--r--src/modules/netlib/netlibhttp.cpp3
-rw-r--r--src/modules/netlib/netlibssl.cpp4
3 files changed, 15 insertions, 14 deletions
diff --git a/src/modules/netlib/netlib.cpp b/src/modules/netlib/netlib.cpp
index 320876ff20..e6fe71ada1 100644
--- a/src/modules/netlib/netlib.cpp
+++ b/src/modules/netlib/netlib.cpp
@@ -279,7 +279,7 @@ INT_PTR NetlibCloseHandle(WPARAM wParam, LPARAM)
HttpGatewayRemovePacket(nlc, -1);
else {
if (nlc->s != INVALID_SOCKET)
- NetlibDoClose(nlc);
+ NetlibDoClose(nlc, nlc->termRequested);
if (nlc->s2 != INVALID_SOCKET) closesocket(nlc->s2);
nlc->s2 = INVALID_SOCKET;
}
@@ -389,18 +389,20 @@ INT_PTR NetlibShutdown(WPARAM wParam, LPARAM)
switch(GetNetlibHandleType((void*)wParam)) {
case NLH_CONNECTION:
{
- struct NetlibConnection* nlc = (struct NetlibConnection*)wParam;
- if (nlc->hSsl) si.shutdown(nlc->hSsl);
- if (nlc->s != INVALID_SOCKET) shutdown(nlc->s, 2);
- if (nlc->s2 != INVALID_SOCKET) shutdown(nlc->s2, 2);
- nlc->termRequested = true;
+ NetlibConnection *nlc = (NetlibConnection*)wParam;
+ if (!nlc->termRequested) {
+ if (nlc->hSsl) si.shutdown(nlc->hSsl);
+ if (nlc->s != INVALID_SOCKET) shutdown(nlc->s, 2);
+ if (nlc->s2 != INVALID_SOCKET) shutdown(nlc->s2, 2);
+ nlc->termRequested = true;
+ }
}
break;
+
case NLH_BOUNDPORT:
- {
- struct NetlibBoundPort* nlb = (struct NetlibBoundPort*)wParam;
- if (nlb->s != INVALID_SOCKET) shutdown(nlb->s, 2);
- }
+ struct NetlibBoundPort* nlb = (struct NetlibBoundPort*)wParam;
+ if (nlb->s != INVALID_SOCKET)
+ shutdown(nlb->s, 2);
break;
}
ReleaseMutex(hConnectionHeaderMutex);
diff --git a/src/modules/netlib/netlibhttp.cpp b/src/modules/netlib/netlibhttp.cpp
index a42e9ea700..36514df345 100644
--- a/src/modules/netlib/netlibhttp.cpp
+++ b/src/modules/netlib/netlibhttp.cpp
@@ -122,7 +122,8 @@ static int RecvWithTimeoutTime(NetlibConnection *nlc, unsigned dwTimeoutTime, ch
return NLRecv(nlc, buf, len, flags);
}
- if (nlc->termRequested || Miranda_Terminated()) return 0;
+ if (nlc->termRequested || Miranda_Terminated())
+ return 0;
}
SetLastError(ERROR_TIMEOUT);
return SOCKET_ERROR;
diff --git a/src/modules/netlib/netlibssl.cpp b/src/modules/netlib/netlibssl.cpp
index 3821c422a3..ccf0219e1f 100644
--- a/src/modules/netlib/netlibssl.cpp
+++ b/src/modules/netlib/netlibssl.cpp
@@ -357,9 +357,7 @@ static SECURITY_STATUS ClientHandshakeLoop(SslHandle *ssl, BOOL fDoInitialRead)
if (scRet == SEC_E_OK) {
// Store remaining data for further use
if (InBuffers[1].BufferType == SECBUFFER_EXTRA) {
- memmove(ssl->pbIoBuffer,
- ssl->pbIoBuffer + (ssl->cbIoBuffer - InBuffers[1].cbBuffer),
- InBuffers[1].cbBuffer);
+ memmove(ssl->pbIoBuffer, ssl->pbIoBuffer + (ssl->cbIoBuffer - InBuffers[1].cbBuffer), InBuffers[1].cbBuffer);
ssl->cbIoBuffer = InBuffers[1].cbBuffer;
}
else ssl->cbIoBuffer = 0;