Juan Lang : crypt32: Decode names using CRYPT_AsnDecodeArrayNoAlloc.

Alexandre Julliard julliard at winehq.org
Thu Oct 15 08:54:35 CDT 2009


Module: wine
Branch: master
Commit: 67ee87664e834cbd0f4ccb74ccd7b10560221c35
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=67ee87664e834cbd0f4ccb74ccd7b10560221c35

Author: Juan Lang <juan.lang at gmail.com>
Date:   Wed Oct 14 13:04:22 2009 -0700

crypt32: Decode names using CRYPT_AsnDecodeArrayNoAlloc.

---

 dlls/crypt32/decode.c |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index 925f632..1179ff2 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -2081,9 +2081,29 @@ static BOOL WINAPI CRYPT_AsnDecodeName(DWORD dwCertEncodingType,
          sizeof(CERT_NAME_INFO),
          CRYPT_AsnDecodeRdn, sizeof(CERT_RDN), TRUE,
          offsetof(CERT_RDN, rgRDNAttr) };
+        DWORD bytesNeeded;
 
-        ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags,
-         pDecodePara, pvStructInfo, pcbStructInfo, NULL, NULL);
+        ret = CRYPT_AsnDecodeArrayNoAlloc(&arrayDesc, pbEncoded, cbEncoded,
+         dwFlags & ~CRYPT_DECODE_ALLOC_FLAG, NULL, &bytesNeeded, NULL);
+        if (ret)
+        {
+            if (!pvStructInfo)
+                *pcbStructInfo = bytesNeeded;
+            else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara,
+             pvStructInfo, pcbStructInfo, bytesNeeded)))
+            {
+                CERT_NAME_INFO *info;
+
+                if (dwFlags & CRYPT_DECODE_ALLOC_FLAG)
+                    pvStructInfo = *(BYTE **)pvStructInfo;
+                info = pvStructInfo;
+                info->rgRDN =
+                 (PCERT_RDN)((BYTE *)pvStructInfo + sizeof(CERT_NAME_INFO));
+                ret = CRYPT_AsnDecodeArrayNoAlloc(&arrayDesc,
+                 pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG,
+                 &info->cRDN, pcbStructInfo, NULL);
+            }
+        }
     }
     __EXCEPT_PAGE_FAULT
     {




More information about the wine-cvs mailing list