Hans Leidekker : secur32: Fix the username fallback in get_key_container_path.

Alexandre Julliard julliard at winehq.org
Fri Feb 22 15:22:11 CST 2019


Module: wine
Branch: master
Commit: ba14773187834d5f6280521bb3c768f7843f246e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ba14773187834d5f6280521bb3c768f7843f246e

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Fri Feb 22 13:59:27 2019 +0100

secur32: Fix the username fallback in get_key_container_path.

Spotted by Sven Baars.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 ea116e81..7c6bb96 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;




More information about the wine-cvs mailing list