Commit 117ea9ee authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Explicitly pass array pointer when decoding basic constraints' subtrees…

crypt32: Explicitly pass array pointer when decoding basic constraints' subtrees rather than assuming a particular alignment.
parent 6d74aac0
...@@ -3804,14 +3804,39 @@ static BOOL CRYPT_AsnDecodeSubtreeConstraints(const BYTE *pbEncoded, ...@@ -3804,14 +3804,39 @@ static BOOL CRYPT_AsnDecodeSubtreeConstraints(const BYTE *pbEncoded,
struct AsnArrayDescriptor arrayDesc = { ASN_SEQUENCEOF, struct AsnArrayDescriptor arrayDesc = { ASN_SEQUENCEOF,
CRYPT_AsnDecodeCopyBytes, sizeof(CERT_NAME_BLOB), TRUE, CRYPT_AsnDecodeCopyBytes, sizeof(CERT_NAME_BLOB), TRUE,
offsetof(CERT_NAME_BLOB, pbData) }; offsetof(CERT_NAME_BLOB, pbData) };
struct GenericArray *entries = pvStructInfo; DWORD bytesNeeded;
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags, TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded); pvStructInfo, *pcbStructInfo, pcbDecoded);
ret = CRYPT_AsnDecodeArray(&arrayDesc, pbEncoded, cbEncoded, dwFlags, ret = CRYPT_AsnDecodeArrayNoAlloc(&arrayDesc, pbEncoded, cbEncoded,
NULL, pvStructInfo, pcbStructInfo, pcbDecoded, NULL, NULL, &bytesNeeded, pcbDecoded);
entries ? entries->rgItems : NULL); if (ret)
{
/* The size expected by the caller includes the combination of
* CERT_BASIC_CONSTRAINTS_INFO's cSubtreesConstraint and
* rgSubtreesConstraint, in addition to the size of all the decoded
* items. CRYPT_AsnDecodeArrayNoAlloc only returns the size of the
* decoded items, so add the size of cSubtreesConstraint and
* rgSubtreesConstraint.
*/
bytesNeeded += FINALMEMBERSIZE(CERT_BASIC_CONSTRAINTS_INFO,
cSubtreesConstraint);
if (!pvStructInfo)
*pcbStructInfo = bytesNeeded;
else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, NULL, pvStructInfo,
pcbStructInfo, bytesNeeded)))
{
CERT_BASIC_CONSTRAINTS_INFO *constraint;
constraint = (CERT_BASIC_CONSTRAINTS_INFO *)
((BYTE *)pvStructInfo -
offsetof(CERT_BASIC_CONSTRAINTS_INFO, cSubtreesConstraint));
ret = CRYPT_AsnDecodeArrayNoAlloc(&arrayDesc, pbEncoded,
cbEncoded, &constraint->cSubtreesConstraint,
constraint->rgSubtreesConstraint, &bytesNeeded, pcbDecoded);
}
}
TRACE("Returning %d (%08x)\n", ret, GetLastError()); TRACE("Returning %d (%08x)\n", ret, GetLastError());
return ret; return ret;
} }
...@@ -3833,7 +3858,8 @@ static BOOL WINAPI CRYPT_AsnDecodeBasicConstraints(DWORD dwCertEncodingType, ...@@ -3833,7 +3858,8 @@ static BOOL WINAPI CRYPT_AsnDecodeBasicConstraints(DWORD dwCertEncodingType,
sizeof(struct PATH_LEN_CONSTRAINT), TRUE, FALSE, 0, 0 }, sizeof(struct PATH_LEN_CONSTRAINT), TRUE, FALSE, 0, 0 },
{ ASN_SEQUENCEOF, offsetof(CERT_BASIC_CONSTRAINTS_INFO, { ASN_SEQUENCEOF, offsetof(CERT_BASIC_CONSTRAINTS_INFO,
cSubtreesConstraint), CRYPT_AsnDecodeSubtreeConstraints, cSubtreesConstraint), CRYPT_AsnDecodeSubtreeConstraints,
sizeof(struct GenericArray), TRUE, TRUE, FINALMEMBERSIZE(CERT_BASIC_CONSTRAINTS_INFO, cSubtreesConstraint),
TRUE, TRUE,
offsetof(CERT_BASIC_CONSTRAINTS_INFO, rgSubtreesConstraint), 0 }, offsetof(CERT_BASIC_CONSTRAINTS_INFO, rgSubtreesConstraint), 0 },
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment