crypt32: Pass length rather than entire message to CRYPT_EncodeContentLength.

This commit is contained in:
Juan Lang 2007-09-18 09:20:17 -07:00 committed by Alexandre Julliard
parent 145d56847b
commit 19956d6e97
1 changed files with 6 additions and 6 deletions

View File

@ -113,7 +113,7 @@ static WINAPI BOOL CRYPT_EncodeContentLength(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)
{ {
const CDataEncodeMsg *msg = (const CDataEncodeMsg *)pvStructInfo; DWORD dataLen = *(DWORD *)pvStructInfo;
DWORD lenBytes; DWORD lenBytes;
BOOL ret = TRUE; BOOL ret = TRUE;
@ -121,9 +121,9 @@ static WINAPI BOOL CRYPT_EncodeContentLength(DWORD dwCertEncodingType,
* the message isn't available yet. The caller will use the length * the message isn't available yet. The caller will use the length
* reported here to encode its length. * reported here to encode its length.
*/ */
CRYPT_EncodeLen(msg->base.stream_info.cbContent, NULL, &lenBytes); CRYPT_EncodeLen(dataLen, NULL, &lenBytes);
if (!pbEncoded) if (!pbEncoded)
*pcbEncoded = 1 + lenBytes + msg->base.stream_info.cbContent; *pcbEncoded = 1 + lenBytes + dataLen;
else else
{ {
if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded, if ((ret = CRYPT_EncodeEnsureSpace(dwFlags, pEncodePara, pbEncoded,
@ -132,7 +132,7 @@ static WINAPI BOOL CRYPT_EncodeContentLength(DWORD dwCertEncodingType,
if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG) if (dwFlags & CRYPT_ENCODE_ALLOC_FLAG)
pbEncoded = *(BYTE **)pbEncoded; pbEncoded = *(BYTE **)pbEncoded;
*pbEncoded++ = ASN_OCTETSTRING; *pbEncoded++ = ASN_OCTETSTRING;
CRYPT_EncodeLen(msg->base.stream_info.cbContent, pbEncoded, CRYPT_EncodeLen(dataLen, pbEncoded,
&lenBytes); &lenBytes);
} }
} }
@ -153,8 +153,8 @@ static BOOL CRYPT_EncodeDataContentInfoHeader(CDataEncodeMsg *msg,
} }
else else
{ {
struct AsnConstructedItem constructed = { 0, msg, struct AsnConstructedItem constructed = { 0,
CRYPT_EncodeContentLength }; &msg->base.stream_info.cbContent, CRYPT_EncodeContentLength };
struct AsnEncodeSequenceItem items[2] = { struct AsnEncodeSequenceItem items[2] = {
{ szOID_RSA_data, CRYPT_AsnEncodeOid, 0 }, { szOID_RSA_data, CRYPT_AsnEncodeOid, 0 },
{ &constructed, CRYPT_AsnEncodeConstructed, 0 }, { &constructed, CRYPT_AsnEncodeConstructed, 0 },