From 15b61357be920bd058dcd5d4d56ef7e059501a82 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Mon, 17 Sep 2007 17:28:09 -0700 Subject: [PATCH] Use correct encoded length when decoding a sequence --- dlls/crypt32/decode.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-) diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c index 1e63183..f0fab24 100644 --- a/dlls/crypt32/decode.c +++ b/dlls/crypt32/decode.c @@ -454,7 +454,7 @@ static BOOL CRYPT_AsnDecodeSequence(stru cbEncoded -= 1 + lenBytes; if (dataLen == CMSG_INDEFINITE_LENGTH) - cbEncoded = dataLen; + dataLen = cbEncoded; else if (cbEncoded < dataLen) { TRACE("dataLen %d exceeds cbEncoded %d, failing\n", dataLen, @@ -462,12 +462,10 @@ static BOOL CRYPT_AsnDecodeSequence(stru SetLastError(CRYPT_E_ASN1_CORRUPT); ret = FALSE; } - else - cbEncoded = dataLen; if (ret) { ret = CRYPT_AsnDecodeSequenceItems(items, cItem, - ptr, cbEncoded, dwFlags, NULL, NULL, &cbDecoded); + ptr, dataLen, dwFlags, NULL, NULL, &cbDecoded); if (ret && dataLen == CMSG_INDEFINITE_LENGTH) { if (cbDecoded > cbEncoded - 2) @@ -487,9 +485,9 @@ static BOOL CRYPT_AsnDecodeSequence(stru 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); SetLastError(CRYPT_E_ASN1_CORRUPT); ret = FALSE; @@ -520,7 +518,7 @@ static BOOL CRYPT_AsnDecodeSequence(stru nextData = (BYTE *)pvStructInfo + structSize; memset(pvStructInfo, 0, structSize); ret = CRYPT_AsnDecodeSequenceItems(items, cItem, - ptr, cbEncoded, dwFlags, pvStructInfo, nextData, + ptr, dataLen, dwFlags, pvStructInfo, nextData, &cbDecoded); } } -- 1.4.1