From e9c44cc0c48203ab239d70af2af9788010eda8f6 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Thu, 16 Feb 2006 12:18:37 +0100 Subject: [PATCH] crypt32: Fix system stores and a memory leak. - system stores open both HKLM and HKCU for "current user" locations - fix a memory leak in certificate properties --- dlls/crypt32/cert.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index c48a5dd730f..6b6a08ddd87 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -1718,12 +1718,27 @@ static PWINECRYPT_CERTSTORE CRYPT_SysOpenStoreW(HCRYPTPROV hCryptProv, { store = CertOpenStore(CERT_STORE_PROV_COLLECTION, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL); - if (store) + CertAddStoreToCollection(store, regStore, + dwFlags & CERT_STORE_READONLY_FLAG ? 0 : + CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); + CertCloseStore(regStore, 0); + /* CERT_SYSTEM_STORE_CURRENT_USER returns both the HKCU and HKLM + * stores. + */ + if ((dwFlags & CERT_SYSTEM_STORE_LOCATION_MASK) == + CERT_SYSTEM_STORE_CURRENT_USER) { - CertAddStoreToCollection(store, regStore, - dwFlags & CERT_STORE_READONLY_FLAG ? 0 : - CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); - CertCloseStore(regStore, 0); + dwFlags &= ~CERT_SYSTEM_STORE_CURRENT_USER; + dwFlags |= CERT_SYSTEM_STORE_LOCAL_MACHINE; + regStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_REGISTRY_W, 0, + hCryptProv, dwFlags, pvPara); + if (regStore) + { + CertAddStoreToCollection(store, regStore, + dwFlags & CERT_STORE_READONLY_FLAG ? 0 : + CERT_PHYSICAL_STORE_ADD_ENABLE_FLAG, 0); + CertCloseStore(regStore, 0); + } } } } @@ -2227,15 +2242,19 @@ static BOOL CRYPT_SaveCertificateContextProperty(PWINE_CERT_CONTEXT context, if (!cbData || data) { PWINE_CERT_PROPERTY prop; + BOOL found = FALSE; EnterCriticalSection(&context->cs); LIST_FOR_EACH_ENTRY(prop, &context->extendedProperties, WINE_CERT_PROPERTY, entry) { if (prop->hdr.propID == dwPropId) + { + found = TRUE; break; + } } - if (prop && prop->entry.next != &context->extendedProperties) + if (found) { CryptMemFree(prop->pbData); prop->hdr.cb = cbData; -- 2.11.4.GIT