From: Dmitry Timoshkov dmitry@baikal.ru
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/crypt32/msg.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c index 5e6d59a1f58..340d7bc3715 100644 --- a/dlls/crypt32/msg.c +++ b/dlls/crypt32/msg.c @@ -746,6 +746,33 @@ static BOOL CRYPT_ConstructBlobArray(DWORD *outCBlobs, return ret; }
+static BOOL CRYPT_AddBlobArray(DWORD *outCBlobs, + PCRYPT_DATA_BLOB *outPBlobs, DWORD cBlobs, const CRYPT_DATA_BLOB *pBlobs) +{ + BOOL ret = TRUE; + + if (cBlobs) + { + CRYPT_DATA_BLOB *new_blobs = CryptMemRealloc(*outPBlobs, (*outCBlobs + cBlobs) * sizeof(CRYPT_DATA_BLOB)); + if (new_blobs) + { + DWORD i; + + *outPBlobs = new_blobs; + + memset(*outPBlobs + *outCBlobs, 0, cBlobs * sizeof(CRYPT_DATA_BLOB)); + for (i = *outCBlobs; ret && i < *outCBlobs + cBlobs; i++) + ret = CRYPT_ConstructBlob(&(*outPBlobs)[i], &pBlobs[i]); + + if (ret) + *outCBlobs += cBlobs; + } + else + ret = FALSE; + } + return ret; +} + static void CRYPT_FreeBlobArray(DWORD cBlobs, PCRYPT_DATA_BLOB blobs) { DWORD i; @@ -3622,6 +3649,23 @@ static BOOL CDecodeMsg_Control(HCRYPTMSG hCryptMsg, DWORD dwFlags, SetLastError(CRYPT_E_INVALID_MSG_TYPE); } break; + case CMSG_CTRL_ADD_CERT: + switch (msg->type) + { + case CMSG_SIGNED: + if (!msg->u.signed_data.info) + { + SetLastError(CRYPT_E_INVALID_MSG_TYPE); + break; + } + ret = CRYPT_AddBlobArray(&msg->u.signed_data.info->cCertEncoded, + &msg->u.signed_data.info->rgCertEncoded, 1, (const CRYPT_DATA_BLOB *)pvCtrlPara); + break; + default: + SetLastError(CRYPT_E_INVALID_MSG_TYPE); + break; + } + break; default: SetLastError(CRYPT_E_CONTROL_TYPE); }