Commit 2d02ec74 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Don't ignore errors when encoding items in an array.

parent e594d240
...@@ -578,27 +578,31 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLEntries(DWORD dwCertEncodingType, ...@@ -578,27 +578,31 @@ static BOOL WINAPI CRYPT_AsnEncodeCRLEntries(DWORD dwCertEncodingType,
if (ret) if (ret)
dataLen += size; dataLen += size;
} }
CRYPT_EncodeLen(dataLen, NULL, &lenBytes); if (ret)
bytesNeeded = 1 + lenBytes + dataLen;
if (!pbEncoded)
*pcbEncoded = bytesNeeded;
else
{ {
if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
pcbEncoded, bytesNeeded))) bytesNeeded = 1 + lenBytes + dataLen;
if (!pbEncoded)
*pcbEncoded = bytesNeeded;
else
{ {
if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded,
pbEncoded = *(BYTE **)pbEncoded; pcbEncoded, bytesNeeded)))
*pbEncoded++ = ASN_SEQUENCEOF;
CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes);
pbEncoded += lenBytes;
for (i = 0; i < cCRLEntry; i++)
{ {
DWORD size = dataLen; if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG)
pbEncoded = *(BYTE **)pbEncoded;
*pbEncoded++ = ASN_SEQUENCEOF;
CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes);
pbEncoded += lenBytes;
for (i = 0; i < cCRLEntry; i++)
{
DWORD size = dataLen;
ret = CRYPT_AsnEncodeCRLEntry(&rgCRLEntry[i], pbEncoded, &size); ret = CRYPT_AsnEncodeCRLEntry(&rgCRLEntry[i], pbEncoded,
pbEncoded += size; &size);
dataLen -= size; pbEncoded += size;
dataLen -= size;
}
} }
} }
} }
...@@ -731,28 +735,31 @@ static BOOL WINAPI CRYPT_AsnEncodeExtensions(DWORD dwCertEncodingType, ...@@ -731,28 +735,31 @@ static BOOL WINAPI CRYPT_AsnEncodeExtensions(DWORD dwCertEncodingType,
if (ret) if (ret)
dataLen += size; dataLen += size;
} }
CRYPT_EncodeLen(dataLen, NULL, &lenBytes); if (ret)
bytesNeeded = 1 + lenBytes + dataLen;
if (!pbEncoded)
*pcbEncoded = bytesNeeded;
else
{ {
if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
pcbEncoded, bytesNeeded))) bytesNeeded = 1 + lenBytes + dataLen;
if (!pbEncoded)
*pcbEncoded = bytesNeeded;
else
{ {
if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
pbEncoded = *(BYTE **)pbEncoded; pbEncoded, pcbEncoded, bytesNeeded)))
*pbEncoded++ = ASN_SEQUENCEOF;
CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes);
pbEncoded += lenBytes;
for (i = 0; i < exts->cExtension; i++)
{ {
DWORD size = dataLen; if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG)
pbEncoded = *(BYTE **)pbEncoded;
*pbEncoded++ = ASN_SEQUENCEOF;
CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes);
pbEncoded += lenBytes;
for (i = 0; i < exts->cExtension; i++)
{
DWORD size = dataLen;
ret = CRYPT_AsnEncodeExtension(&exts->rgExtension[i], ret = CRYPT_AsnEncodeExtension(&exts->rgExtension[i],
pbEncoded, &size); pbEncoded, &size);
pbEncoded += size; pbEncoded += size;
dataLen -= size; dataLen -= size;
}
} }
} }
} }
...@@ -1459,29 +1466,32 @@ static BOOL WINAPI CRYPT_AsnEncodeSMIMECapabilities(DWORD dwCertEncodingType, ...@@ -1459,29 +1466,32 @@ static BOOL WINAPI CRYPT_AsnEncodeSMIMECapabilities(DWORD dwCertEncodingType,
if (ret) if (ret)
dataLen += size; dataLen += size;
} }
CRYPT_EncodeLen(dataLen, NULL, &lenBytes); if (ret)
bytesNeeded = 1 + lenBytes + dataLen;
if (!pbEncoded)
*pcbEncoded = bytesNeeded;
else
{ {
if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
pcbEncoded, bytesNeeded))) bytesNeeded = 1 + lenBytes + dataLen;
if (!pbEncoded)
*pcbEncoded = bytesNeeded;
else
{ {
if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara,
pbEncoded = *(BYTE **)pbEncoded; pbEncoded, pcbEncoded, bytesNeeded)))
*pbEncoded++ = ASN_SEQUENCEOF;
CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes);
pbEncoded += lenBytes;
for (i = 0; i < capabilities->cCapability; i++)
{ {
DWORD size = dataLen; if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG)
pbEncoded = *(BYTE **)pbEncoded;
*pbEncoded++ = ASN_SEQUENCEOF;
CRYPT_EncodeLen(dataLen, pbEncoded, &lenBytes);
pbEncoded += lenBytes;
for (i = 0; i < capabilities->cCapability; i++)
{
DWORD size = dataLen;
ret = CRYPT_AsnEncodeSMIMECapability(dwCertEncodingType, ret = CRYPT_AsnEncodeSMIMECapability(dwCertEncodingType,
NULL, &capabilities->rgCapability[i], 0, NULL, pbEncoded, NULL, &capabilities->rgCapability[i], 0, NULL,
&size); pbEncoded, &size);
pbEncoded += size; pbEncoded += size;
dataLen -= size; dataLen -= size;
}
} }
} }
} }
......
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