Module: wine Branch: master Commit: 330d6ab88f17672543e9287643f68f6880b93130 URL: https://gitlab.winehq.org/wine/wine/-/commit/330d6ab88f17672543e9287643f68f6...
Author: Paul Gofman pgofman@codeweavers.com Date: Wed Mar 22 15:55:06 2023 -0600
crypt32: Refactor CRYPT_ImportSystemRootCertsToReg().
---
dlls/crypt32/rootstore.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/dlls/crypt32/rootstore.c b/dlls/crypt32/rootstore.c index ab3a396b651..fb90c5bde7c 100644 --- a/dlls/crypt32/rootstore.c +++ b/dlls/crypt32/rootstore.c @@ -657,7 +657,7 @@ static HCERTSTORE create_root_store(void) void CRYPT_ImportSystemRootCertsToReg(void) { HCERTSTORE store = NULL; - HKEY key; + HKEY key = NULL; LONG rc; HANDLE hsem;
@@ -674,24 +674,28 @@ void CRYPT_ImportSystemRootCertsToReg(void) }
if(GetLastError() == ERROR_ALREADY_EXISTS) + { WaitForSingleObject(hsem, INFINITE); - else + goto done; + } + + rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\Microsoft\SystemCertificates\Root\Certificates", 0, NULL, 0, + KEY_ALL_ACCESS, NULL, &key, 0); + if (rc) + goto done; + + if (!(store = create_root_store())) { - if ((store = create_root_store())) - { - rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, L"Software\Microsoft\SystemCertificates\Root\Certificates", 0, NULL, 0, - KEY_ALL_ACCESS, NULL, &key, 0); - if (!rc) - { - if (!CRYPT_SerializeContextsToReg(key, REG_OPTION_VOLATILE, pCertInterface, store)) - ERR("Failed to import system certs into registry, %08lx\n", GetLastError()); - RegCloseKey(key); - } - CertCloseStore(store, 0); - } else - ERR("Failed to create root store\n"); + ERR("Failed to create root store\n"); + goto done; }
+ if (!CRYPT_SerializeContextsToReg(key, REG_OPTION_VOLATILE, pCertInterface, store)) + ERR("Failed to import system certs into registry, %08lx\n", GetLastError()); + +done: + RegCloseKey(key); + CertCloseStore(store, 0); root_certs_imported = TRUE; ReleaseSemaphore(hsem, 1, NULL); CloseHandle(hsem);