[PATCH] secur32: Fix the username fallback in get_key_container_path.

Hans Leidekker hans at codeweavers.com
Fri Feb 22 06:59:27 CST 2019


Spotted by Sven Baars.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/secur32/schannel_gnutls.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/dlls/secur32/schannel_gnutls.c b/dlls/secur32/schannel_gnutls.c
index ea116e81da..7c6bb96f38 100644
--- a/dlls/secur32/schannel_gnutls.c
+++ b/dlls/secur32/schannel_gnutls.c
@@ -599,13 +599,12 @@ static WCHAR *get_key_container_path(const CERT_CONTEXT *ctx)
 {
     static const WCHAR rsabaseW[] =
         {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\','C','r','y','p','t','o','\\','R','S','A','\\',0};
-    DWORD size;
     CERT_KEY_CONTEXT keyctx;
+    DWORD size = sizeof(keyctx), prov_size = 0;
     CRYPT_KEY_PROV_INFO *prov;
     WCHAR username[UNLEN + 1], *ret = NULL;
     DWORD len = ARRAY_SIZE(username);
 
-    size = sizeof(keyctx);
     if (CertGetCertificateContextProperty(ctx, CERT_KEY_CONTEXT_PROP_ID, &keyctx, &size))
     {
         char *str;
@@ -623,12 +622,10 @@ static WCHAR *get_key_container_path(const CERT_CONTEXT *ctx)
         MultiByteToWideChar(CP_ACP, 0, str, -1, ret + strlenW(ret), len);
         heap_free(str);
     }
-    else
+    else if (CertGetCertificateContextProperty(ctx, CERT_KEY_PROV_INFO_PROP_ID, NULL, &prov_size))
     {
-        size = 0;
-        if (!CertGetCertificateContextProperty(ctx, CERT_KEY_PROV_INFO_PROP_ID, NULL, &size)) return NULL;
-        if (!(prov = heap_alloc(size))) return NULL;
-        if (!CertGetCertificateContextProperty(ctx, CERT_KEY_PROV_INFO_PROP_ID, prov, &size))
+        if (!(prov = heap_alloc(prov_size))) return NULL;
+        if (!CertGetCertificateContextProperty(ctx, CERT_KEY_PROV_INFO_PROP_ID, prov, &prov_size))
         {
             heap_free(prov);
             return NULL;
-- 
2.20.1




More information about the wine-devel mailing list