Commit d5d3efd5 authored by Alexandre Julliard's avatar Alexandre Julliard

crypt32: Fix a couple of assumptions about structure layout.

parent 72a95ffa
...@@ -523,7 +523,7 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[], ...@@ -523,7 +523,7 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[],
for (i = 0; i < cItem; i++) for (i = 0; i < cItem; i++)
{ {
bytesNeeded += items[i].size; bytesNeeded += items[i].size;
structSize += items[i].minSize; structSize = max( structSize, items[i].offset + items[i].minSize );
} }
if (pcbDecoded) if (pcbDecoded)
*pcbDecoded = 1 + lenBytes + cbDecoded; *pcbDecoded = 1 + lenBytes + cbDecoded;
......
...@@ -564,13 +564,12 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLEntries(DWORD dwCertEncodingType, ...@@ -564,13 +564,12 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLEntries(DWORD dwCertEncodingType,
LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags, LPCSTR lpszStructType, const void *pvStructInfo, DWORD dwFlags,
PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded) PCRYPT_ENCODE_PARA pEncodePara, BYTE *pbEncoded, DWORD *pcbEncoded)
{ {
DWORD cCRLEntry = *(const DWORD *)pvStructInfo;
DWORD bytesNeeded, dataLen, lenBytes, i; DWORD bytesNeeded, dataLen, lenBytes, i;
const CRL_ENTRY *rgCRLEntry = *(const CRL_ENTRY *const *) const CRL_INFO *info = pvStructInfo;
((const BYTE *)pvStructInfo + sizeof(DWORD)); const CRL_ENTRY *rgCRLEntry = info->rgCRLEntry;
BOOL ret = TRUE; BOOL ret = TRUE;
for (i = 0, dataLen = 0; ret && i < cCRLEntry; i++) for (i = 0, dataLen = 0; ret && i < info->cCRLEntry; i++)
{ {
DWORD size; DWORD size;
...@@ -594,7 +593,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLEntries(DWORD dwCertEncodingType, ...@@ -594,7 +593,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLEntries(DWORD dwCertEncodingType,
*pbEncoded++ = ASN_SEQUENCEOF; *pbEncoded++ = ASN_SEQUENCEOF;
CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes); CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes);
pbEncoded += lenBytes; pbEncoded += lenBytes;
for (i = 0; i < cCRLEntry; i++) for (i = 0; i < info->cCRLEntry; i++)
{ {
DWORD size = dataLen; DWORD size = dataLen;
...@@ -659,7 +658,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLInfo(DWORD dwCertEncodingType, ...@@ -659,7 +658,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLInfo(DWORD dwCertEncodingType,
} }
if (info->cCRLEntry) if (info->cCRLEntry)
{ {
items[cItem].pvStructInfo = &info->cCRLEntry; items[cItem].pvStructInfo = info;
items[cItem].encodeFunc = CRYPT_AsnEncodeCRLEntries; items[cItem].encodeFunc = CRYPT_AsnEncodeCRLEntries;
cItem++; cItem++;
} }
......
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