Juan Lang : crypt32: Fix race condition in loading default provider.
Alexandre Julliard
julliard at winehq.org
Tue Jan 15 07:47:10 CST 2008
Module: wine
Branch: master
Commit: 5c8aa89163fabc0496c96deeabd3775b2c9116cc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5c8aa89163fabc0496c96deeabd3775b2c9116cc
Author: Juan Lang <juan.lang at gmail.com>
Date: Mon Jan 14 11:15:35 2008 -0800
crypt32: Fix race condition in loading default provider.
---
dlls/crypt32/main.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/crypt32/main.c b/dlls/crypt32/main.c
index fa90ee0..922dd19 100644
--- a/dlls/crypt32/main.c
+++ b/dlls/crypt32/main.c
@@ -59,8 +59,16 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
HCRYPTPROV CRYPT_GetDefaultProvider(void)
{
if (!hDefProv)
- CryptAcquireContextW(&hDefProv, NULL, MS_ENHANCED_PROV_W,
- PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
+ {
+ HCRYPTPROV prov;
+
+ CryptAcquireContextW(&prov, NULL, MS_ENHANCED_PROV_W, PROV_RSA_FULL,
+ CRYPT_VERIFYCONTEXT);
+ InterlockedCompareExchangePointer((PVOID *)&hDefProv, (PVOID)prov,
+ NULL);
+ if (hDefProv != prov)
+ CryptReleaseContext(prov, 0);
+ }
return hDefProv;
}
More information about the wine-cvs
mailing list