From 9d63e6f944d570c9e0dac175d6ecf4f2df4e45f9 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Mon, 21 Nov 2011 19:52:31 +0400 Subject: [PATCH] crypt32: Initialize a pointer for dynamic data. --- dlls/crypt32/decode.c | 25 +++++++++++++++++++++++++ dlls/crypt32/tests/encode.c | 13 +------------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c index 649ca55da89..4a225331d6d 100644 --- a/dlls/crypt32/decode.c +++ b/dlls/crypt32/decode.c @@ -1465,7 +1465,10 @@ static BOOL WINAPI CRYPT_AsnDecodeExtensions(DWORD dwCertEncodingType, sizeof(CERT_EXTENSIONS), CRYPT_AsnDecodeExtension, sizeof(CERT_EXTENSION), TRUE, offsetof(CERT_EXTENSION, pszObjId) }; + CERT_EXTENSIONS *exts = pvStructInfo; + if (pvStructInfo && !(dwFlags & CRYPT_DECODE_ALLOC_FLAG)) + exts->rgExtension = (CERT_EXTENSION *)(exts + 1); ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); } @@ -2356,7 +2359,10 @@ static BOOL WINAPI CRYPT_AsnDecodeSMIMECapabilities(DWORD dwCertEncodingType, sizeof(CRYPT_SMIME_CAPABILITIES), CRYPT_AsnDecodeSMIMECapability, sizeof(CRYPT_SMIME_CAPABILITY), TRUE, offsetof(CRYPT_SMIME_CAPABILITY, pszObjId) }; + CRYPT_SMIME_CAPABILITIES *capabilities = pvStructInfo; + if (pvStructInfo && !(dwFlags & CRYPT_DECODE_ALLOC_FLAG)) + capabilities->rgCapability = (CRYPT_SMIME_CAPABILITY *)(capabilities + 1); ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); } @@ -2832,7 +2838,10 @@ static BOOL WINAPI CRYPT_AsnDecodePKCSAttributes(DWORD dwCertEncodingType, sizeof(CRYPT_ATTRIBUTES), CRYPT_AsnDecodePKCSAttributeInternal, sizeof(CRYPT_ATTRIBUTE), TRUE, offsetof(CRYPT_ATTRIBUTE, pszObjId) }; + CRYPT_ATTRIBUTES *attrs = pvStructInfo; + if (pvStructInfo && !(dwFlags & CRYPT_DECODE_ALLOC_FLAG)) + attrs->rgAttr = (CRYPT_ATTRIBUTE *)(attrs + 1); ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); } @@ -3232,7 +3241,10 @@ static BOOL WINAPI CRYPT_AsnDecodeAuthorityInfoAccess(DWORD dwCertEncodingType, sizeof(CERT_AUTHORITY_INFO_ACCESS), CRYPT_AsnDecodeAccessDescription, sizeof(CERT_ACCESS_DESCRIPTION), TRUE, offsetof(CERT_ACCESS_DESCRIPTION, pszAccessMethod) }; + CERT_AUTHORITY_INFO_ACCESS *info = pvStructInfo; + if (pvStructInfo && !(dwFlags & CRYPT_DECODE_ALLOC_FLAG)) + info->rgAccDescr = (CERT_ACCESS_DESCRIPTION *)(info + 1); ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); } @@ -3653,6 +3665,10 @@ static BOOL WINAPI CRYPT_AsnDecodeCertPolicies(DWORD dwCertEncodingType, sizeof(CERT_POLICIES_INFO), CRYPT_AsnDecodeCertPolicy, sizeof(CERT_POLICY_INFO), TRUE, offsetof(CERT_POLICY_INFO, pszPolicyIdentifier) }; + CERT_POLICIES_INFO *info = pvStructInfo; + + if (pvStructInfo && !(dwFlags & CRYPT_DECODE_ALLOC_FLAG)) + info->rgPolicyInfo = (CERT_POLICY_INFO *)(info + 1); ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); @@ -3706,7 +3722,10 @@ static BOOL WINAPI CRYPT_AsnDecodeCertPolicyMappings(DWORD dwCertEncodingType, sizeof(CERT_POLICY_MAPPING), CRYPT_AsnDecodeCertPolicyMapping, sizeof(CERT_POLICY_MAPPING), TRUE, offsetof(CERT_POLICY_MAPPING, pszIssuerDomainPolicy) }; + CERT_POLICY_MAPPINGS_INFO *info = pvStructInfo; + if (pvStructInfo && !(dwFlags & CRYPT_DECODE_ALLOC_FLAG)) + info->rgPolicyMapping = (CERT_POLICY_MAPPING *)(info + 1); ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); } @@ -5020,7 +5039,10 @@ static BOOL WINAPI CRYPT_AsnDecodeCRLDistPoints(DWORD dwCertEncodingType, sizeof(CRL_DIST_POINTS_INFO), CRYPT_AsnDecodeDistPoint, sizeof(CRL_DIST_POINT), TRUE, offsetof(CRL_DIST_POINT, DistPointName.u.FullName.rgAltEntry) }; + CRL_DIST_POINTS_INFO *info = pvStructInfo; + if (pvStructInfo && !(dwFlags & CRYPT_DECODE_ALLOC_FLAG)) + info->rgDistPoint = (CRL_DIST_POINT *)(info + 1); ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); } @@ -5049,7 +5071,10 @@ static BOOL WINAPI CRYPT_AsnDecodeEnhancedKeyUsage(DWORD dwCertEncodingType, offsetof(CERT_ENHKEY_USAGE, rgpszUsageIdentifier), sizeof(CERT_ENHKEY_USAGE), CRYPT_AsnDecodeOidInternal, sizeof(LPSTR), TRUE, 0 }; + CERT_ENHKEY_USAGE *usage = pvStructInfo; + if (pvStructInfo && !(dwFlags & CRYPT_DECODE_ALLOC_FLAG)) + usage->rgpszUsageIdentifier = (LPSTR *)(usage + 1); ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL); } diff --git a/dlls/crypt32/tests/encode.c b/dlls/crypt32/tests/encode.c index d74b1c9d8d0..5d9e76be04f 100644 --- a/dlls/crypt32/tests/encode.c +++ b/dlls/crypt32/tests/encode.c @@ -2718,11 +2718,7 @@ static void test_decodeExtensions(DWORD dwEncoding) { ret = pCryptDecodeObjectEx(dwEncoding, X509_EXTENSIONS, exts[i].encoded, exts[i].encoded[1] + 2, 0, NULL, buf, &bufSize); - if (!i) - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); - else - todo_wine - ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); + ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); HeapFree(GetProcessHeap(), 0, buf); } } @@ -3626,7 +3622,6 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding) ret = pCryptDecodeObjectEx(dwEncoding, X509_CRL_DIST_POINTS, distPointWithUrlAndIssuer, distPointWithUrlAndIssuer[1] + 2, 0, NULL, buf, &size); - todo_wine ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); HeapFree(GetProcessHeap(), 0, buf); } @@ -4778,7 +4773,6 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding) { ret = pCryptDecodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, encodedUsage, sizeof(encodedUsage), 0, NULL, buf, &size); - todo_wine ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); HeapFree(GetProcessHeap(), 0, buf); } @@ -5266,7 +5260,6 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding) ret = pCryptDecodeObjectEx(dwEncoding, X509_AUTHORITY_INFO_ACCESS, authorityInfoAccessWithUrlAndIPAddr, sizeof(authorityInfoAccessWithUrlAndIPAddr), 0, NULL, buf, &size); - todo_wine ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); HeapFree(GetProcessHeap(), 0, buf); } @@ -6231,7 +6224,6 @@ static void test_decodePKCSAttributes(DWORD dwEncoding) { ret = pCryptDecodeObjectEx(dwEncoding, PKCS_ATTRIBUTES, doublePKCSAttributes, sizeof(doublePKCSAttributes), 0, NULL, buf, &size); - todo_wine ok(ret, "CryptDecodeObjectEx failed: %x\n", GetLastError()); HeapFree(GetProcessHeap(), 0, buf); } @@ -6402,7 +6394,6 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding) SetLastError(0xdeadbeef); ret = pCryptDecodeObjectEx(dwEncoding, PKCS_SMIME_CAPABILITIES, twoCapabilities, sizeof(twoCapabilities), 0, NULL, ptr, &size); - todo_wine ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); HeapFree(GetProcessHeap(), 0, ptr); } @@ -7576,7 +7567,6 @@ static void test_decodeCertPolicies(DWORD dwEncoding) { ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_POLICIES, twoPolicies, sizeof(twoPolicies), 0, NULL, info, &size); - todo_wine ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); HeapFree(GetProcessHeap(), 0, info); } @@ -7733,7 +7723,6 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding) ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i], policyMappingWithTwoMappings, sizeof(policyMappingWithTwoMappings), 0, NULL, info, &size); - todo_wine ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); HeapFree(GetProcessHeap(), 0, info); }