diff options
-rw-r--r-- | src/modules/netlib/netlib.cpp | 1 | ||||
-rw-r--r-- | src/modules/netlib/netlib.h | 1 | ||||
-rw-r--r-- | src/modules/netlib/netlibsecurity.cpp | 30 |
3 files changed, 10 insertions, 22 deletions
diff --git a/src/modules/netlib/netlib.cpp b/src/modules/netlib/netlib.cpp index bc833c9195..a900c77f93 100644 --- a/src/modules/netlib/netlib.cpp +++ b/src/modules/netlib/netlib.cpp @@ -415,7 +415,6 @@ void UnloadNetlibModule(void) if (!bModuleInitialized || hConnectionHeaderMutex == NULL) return;
NetlibUnloadIeProxy();
- NetlibSecurityDestroy();
NetlibUPnPDestroy();
NetlibLogShutdown();
diff --git a/src/modules/netlib/netlib.h b/src/modules/netlib/netlib.h index 2586298c8d..949d1755b2 100644 --- a/src/modules/netlib/netlib.h +++ b/src/modules/netlib/netlib.h @@ -203,7 +203,6 @@ void NetlibUPnPDestroy(void); //netlibsecurity.c
void NetlibSecurityInit(void);
-void NetlibSecurityDestroy(void);
void NetlibDestroySecurityProvider(HANDLE hSecurity);
HANDLE NetlibInitSecurityProvider(const TCHAR* szProvider, const TCHAR* szPrincipal);
HANDLE NetlibInitSecurityProvider(const char* szProvider, const char* szPrincipal);
diff --git a/src/modules/netlib/netlibsecurity.cpp b/src/modules/netlib/netlibsecurity.cpp index 10a322453d..6533a1fa5f 100644 --- a/src/modules/netlib/netlibsecurity.cpp +++ b/src/modules/netlib/netlibsecurity.cpp @@ -61,7 +61,7 @@ struct NtlmType2packet };
static unsigned secCnt = 0, ntlmCnt = 0;
-static HANDLE hSecMutex;
+static mir_cs csSec;
static void ReportSecError(SECURITY_STATUS scRet, int line)
{
@@ -116,7 +116,7 @@ HANDLE NetlibInitSecurityProvider(const TCHAR* szProvider, const TCHAR* szPrinci return hNtlm;
}
- WaitForSingleObject(hSecMutex, INFINITE);
+ mir_cslock lck(csSec);
if (secCnt == 0) {
LoadSecurityLibrary();
@@ -143,8 +143,6 @@ HANDLE NetlibInitSecurityProvider(const TCHAR* szProvider, const TCHAR* szPrinci ntlmCnt++;
}
}
-
- ReleaseMutex(hSecMutex);
return hSecurity;
}
@@ -158,24 +156,23 @@ void NetlibDestroySecurityProvider(HANDLE hSecurity) if (hSecurity == NULL)
return;
- WaitForSingleObject(hSecMutex, INFINITE);
+ mir_cslock lck(csSec);
if (ntlmCnt != 0) {
NtlmHandleType* hNtlm = (NtlmHandleType*)hSecurity;
- if (SecIsValidHandle(&hNtlm->hClientContext)) g_pSSPI->DeleteSecurityContext(&hNtlm->hClientContext);
- if (SecIsValidHandle(&hNtlm->hClientCredential)) g_pSSPI->FreeCredentialsHandle(&hNtlm->hClientCredential);
- mir_free(hNtlm->szProvider);
- mir_free(hNtlm->szPrincipal);
+ if (hNtlm != NULL) {
+ if (SecIsValidHandle(&hNtlm->hClientContext)) g_pSSPI->DeleteSecurityContext(&hNtlm->hClientContext);
+ if (SecIsValidHandle(&hNtlm->hClientCredential)) g_pSSPI->FreeCredentialsHandle(&hNtlm->hClientCredential);
+ mir_free(hNtlm->szProvider);
+ mir_free(hNtlm->szPrincipal);
+ mir_free(hNtlm);
+ }
--ntlmCnt;
-
- mir_free(hNtlm);
}
if (secCnt && --secCnt == 0)
FreeSecurityLibrary();
-
- ReleaseMutex(hSecMutex);
}
char* CompleteGssapi(HANDLE hSecurity, unsigned char *szChallenge, unsigned chlsz)
@@ -458,16 +455,9 @@ static INT_PTR NtlmCreateResponseService2(WPARAM wParam, LPARAM lParam) void NetlibSecurityInit(void)
{
- hSecMutex = CreateMutex(NULL, FALSE, NULL);
-
CreateServiceFunction(MS_NETLIB_INITSECURITYPROVIDER, InitSecurityProviderService);
CreateServiceFunction(MS_NETLIB_INITSECURITYPROVIDER2, InitSecurityProviderService2);
CreateServiceFunction(MS_NETLIB_DESTROYSECURITYPROVIDER, DestroySecurityProviderService);
CreateServiceFunction(MS_NETLIB_NTLMCREATERESPONSE, NtlmCreateResponseService);
CreateServiceFunction(MS_NETLIB_NTLMCREATERESPONSE2, NtlmCreateResponseService2);
}
-
-void NetlibSecurityDestroy(void)
-{
- CloseHandle(hSecMutex);
-}
|