From 8882936073aa878b6519264288389896338328dc Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Fri, 19 Oct 2007 03:48:50 -0700 Subject: [PATCH] crypt32: Keep signer handle count separate from signer info. --- dlls/crypt32/msg.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 193396f28dd..30c0ddbb1a1 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -806,6 +806,7 @@ typedef struct _CSignerHandles typedef struct _CSignedMsgData { CRYPT_SIGNED_INFO *info; + DWORD cSignerHandle; CSignerHandles *signerHandles; } CSignedMsgData; @@ -841,13 +842,22 @@ static BOOL CSignedMsgData_AllocateHandles(CSignedMsgData *msg_data) msg_data->signerHandles = CryptMemAlloc(msg_data->info->cSignerInfo * sizeof(CSignerHandles)); if (msg_data->signerHandles) + { + msg_data->cSignerHandle = msg_data->info->cSignerInfo; memset(msg_data->signerHandles, 0, msg_data->info->cSignerInfo * sizeof(CSignerHandles)); + } else + { + msg_data->cSignerHandle = 0; ret = FALSE; + } } else + { + msg_data->cSignerHandle = 0; msg_data->signerHandles = NULL; + } return ret; } @@ -855,7 +865,7 @@ static void CSignedMsgData_CloseHandles(CSignedMsgData *msg_data) { DWORD i; - for (i = 0; i < msg_data->info->cSignerInfo; i++) + for (i = 0; i < msg_data->cSignerHandle; i++) { if (msg_data->signerHandles[i].contentHash) CryptDestroyHash(msg_data->signerHandles[i].contentHash); @@ -863,6 +873,8 @@ static void CSignedMsgData_CloseHandles(CSignedMsgData *msg_data) CryptDestroyHash(msg_data->signerHandles[i].authAttrHash); } CryptMemFree(msg_data->signerHandles); + msg_data->signerHandles = NULL; + msg_data->cSignerHandle = 0; } static BOOL CSignedMsgData_UpdateHash(CSignedMsgData *msg_data, @@ -871,7 +883,7 @@ static BOOL CSignedMsgData_UpdateHash(CSignedMsgData *msg_data, DWORD i; BOOL ret = TRUE; - for (i = 0; ret && i < msg_data->info->cSignerInfo; i++) + for (i = 0; ret && i < msg_data->cSignerHandle; i++) ret = CryptHashData(msg_data->signerHandles[i].contentHash, pbData, cbData, 0); return ret; @@ -1140,7 +1152,7 @@ static BOOL CSignedEncodeMsg_GetParam(HCRYPTMSG hCryptMsg, DWORD dwParamType, break; } case CMSG_COMPUTED_HASH_PARAM: - if (dwIndex >= msg->msg_data.info->cSignerInfo) + if (dwIndex >= msg->msg_data.cSignerHandle) SetLastError(CRYPT_E_INVALID_INDEX); else ret = CryptGetHashParam( @@ -1279,6 +1291,7 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags, { msg->msg_data.info->cSignerInfo = 0; msg->msg_data.signerHandles = NULL; + msg->msg_data.cSignerHandle = 0; } } if (ret) @@ -2023,7 +2036,7 @@ static BOOL CDecodeSignedMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType, case CMSG_COMPUTED_HASH_PARAM: if (msg->u.signed_data.info) { - if (dwIndex >= msg->u.signed_data.info->cSignerInfo) + if (dwIndex >= msg->u.signed_data.cSignerHandle) SetLastError(CRYPT_E_INVALID_INDEX); else ret = CryptGetHashParam( -- 2.11.4.GIT