Commit 43e6b48b authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Use correct encoded length when decoding a sequence.

parent f534a67b
...@@ -454,7 +454,7 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[], ...@@ -454,7 +454,7 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[],
cbEncoded -= 1 + lenBytes; cbEncoded -= 1 + lenBytes;
if (dataLen == CMSG_INDEFINITE_LENGTH) if (dataLen == CMSG_INDEFINITE_LENGTH)
cbEncoded = dataLen; dataLen = cbEncoded;
else if (cbEncoded < dataLen) else if (cbEncoded < dataLen)
{ {
TRACE("dataLen %d exceeds cbEncoded %d, failing\n", dataLen, TRACE("dataLen %d exceeds cbEncoded %d, failing\n", dataLen,
...@@ -462,12 +462,10 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[], ...@@ -462,12 +462,10 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[],
SetLastError(CRYPT_E_ASN1_CORRUPT); SetLastError(CRYPT_E_ASN1_CORRUPT);
ret = FALSE; ret = FALSE;
} }
else
cbEncoded = dataLen;
if (ret) if (ret)
{ {
ret = CRYPT_AsnDecodeSequenceItems(items, cItem, ret = CRYPT_AsnDecodeSequenceItems(items, cItem,
ptr, cbEncoded, dwFlags, NULL, NULL, &cbDecoded); ptr, dataLen, dwFlags, NULL, NULL, &cbDecoded);
if (ret && dataLen == CMSG_INDEFINITE_LENGTH) if (ret && dataLen == CMSG_INDEFINITE_LENGTH)
{ {
if (cbDecoded > cbEncoded - 2) if (cbDecoded > cbEncoded - 2)
...@@ -487,9 +485,9 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[], ...@@ -487,9 +485,9 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[],
cbDecoded += 2; cbDecoded += 2;
} }
} }
if (ret && cbDecoded != cbEncoded) if (ret && cbDecoded != dataLen)
{ {
TRACE("expected %d decoded, got %d, failing\n", cbEncoded, TRACE("expected %d decoded, got %d, failing\n", dataLen,
cbDecoded); cbDecoded);
SetLastError(CRYPT_E_ASN1_CORRUPT); SetLastError(CRYPT_E_ASN1_CORRUPT);
ret = FALSE; ret = FALSE;
...@@ -520,7 +518,7 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[], ...@@ -520,7 +518,7 @@ static BOOL CRYPT_AsnDecodeSequence(struct AsnDecodeSequenceItem items[],
nextData = (BYTE *)pvStructInfo + structSize; nextData = (BYTE *)pvStructInfo + structSize;
memset(pvStructInfo, 0, structSize); memset(pvStructInfo, 0, structSize);
ret = CRYPT_AsnDecodeSequenceItems(items, cItem, ret = CRYPT_AsnDecodeSequenceItems(items, cItem,
ptr, cbEncoded, dwFlags, pvStructInfo, nextData, ptr, dataLen, dwFlags, pvStructInfo, nextData,
&cbDecoded); &cbDecoded);
} }
} }
......
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