Commit 3000bc20 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Explicitly pass pointers to blob arrays rather than relying on an…

crypt32: Explicitly pass pointers to blob arrays rather than relying on an invalid alignment assumption.
parent 5f317d70
...@@ -719,27 +719,22 @@ static BOOL CRYPT_ConstructBlob(CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in) ...@@ -719,27 +719,22 @@ static BOOL CRYPT_ConstructBlob(CRYPT_DATA_BLOB *out, const CRYPT_DATA_BLOB *in)
return ret; return ret;
} }
typedef struct _BlobArray static BOOL CRYPT_ConstructBlobArray(DWORD *outCBlobs,
{ PCRYPT_DATA_BLOB *outPBlobs, DWORD cBlobs, const PCRYPT_DATA_BLOB pBlobs)
DWORD cBlobs;
PCRYPT_DATA_BLOB blobs;
} BlobArray;
static BOOL CRYPT_ConstructBlobArray(BlobArray *out, const BlobArray *in)
{ {
BOOL ret = TRUE; BOOL ret = TRUE;
out->cBlobs = in->cBlobs; *outCBlobs = cBlobs;
if (out->cBlobs) if (cBlobs)
{ {
out->blobs = CryptMemAlloc(out->cBlobs * sizeof(CRYPT_DATA_BLOB)); *outPBlobs = CryptMemAlloc(cBlobs * sizeof(CRYPT_DATA_BLOB));
if (out->blobs) if (*outPBlobs)
{ {
DWORD i; DWORD i;
memset(out->blobs, 0, out->cBlobs * sizeof(CRYPT_DATA_BLOB)); memset(*outPBlobs, 0, cBlobs * sizeof(CRYPT_DATA_BLOB));
for (i = 0; ret && i < out->cBlobs; i++) for (i = 0; ret && i < cBlobs; i++)
ret = CRYPT_ConstructBlob(&out->blobs[i], &in->blobs[i]); ret = CRYPT_ConstructBlob(&(*outPBlobs)[i], &pBlobs[i]);
} }
else else
ret = FALSE; ret = FALSE;
...@@ -747,6 +742,12 @@ static BOOL CRYPT_ConstructBlobArray(BlobArray *out, const BlobArray *in) ...@@ -747,6 +742,12 @@ static BOOL CRYPT_ConstructBlobArray(BlobArray *out, const BlobArray *in)
return ret; return ret;
} }
typedef struct _BlobArray
{
DWORD cBlobs;
PCRYPT_DATA_BLOB blobs;
} BlobArray;
static void CRYPT_FreeBlobArray(BlobArray *array) static void CRYPT_FreeBlobArray(BlobArray *array)
{ {
DWORD i; DWORD i;
...@@ -765,8 +766,8 @@ static BOOL CRYPT_ConstructAttribute(CRYPT_ATTRIBUTE *out, ...@@ -765,8 +766,8 @@ static BOOL CRYPT_ConstructAttribute(CRYPT_ATTRIBUTE *out,
if (out->pszObjId) if (out->pszObjId)
{ {
strcpy(out->pszObjId, in->pszObjId); strcpy(out->pszObjId, in->pszObjId);
ret = CRYPT_ConstructBlobArray((BlobArray *)&out->cValue, ret = CRYPT_ConstructBlobArray(&out->cValue, &out->rgValue,
(const BlobArray *)&in->cValue); in->cValue, in->rgValue);
} }
else else
ret = FALSE; ret = FALSE;
...@@ -1435,13 +1436,13 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags, ...@@ -1435,13 +1436,13 @@ static HCRYPTMSG CSignedEncodeMsg_Open(DWORD dwFlags,
} }
} }
if (ret) if (ret)
ret = CRYPT_ConstructBlobArray( ret = CRYPT_ConstructBlobArray(&msg->msg_data.info->cCertEncoded,
(BlobArray *)&msg->msg_data.info->cCertEncoded, &msg->msg_data.info->rgCertEncoded, info->cCertEncoded,
(const BlobArray *)&info->cCertEncoded); info->rgCertEncoded);
if (ret) if (ret)
ret = CRYPT_ConstructBlobArray( ret = CRYPT_ConstructBlobArray(&msg->msg_data.info->cCrlEncoded,
(BlobArray *)&msg->msg_data.info->cCrlEncoded, &msg->msg_data.info->rgCrlEncoded, info->cCrlEncoded,
(const BlobArray *)&info->cCrlEncoded); info->rgCrlEncoded);
if (!ret) if (!ret)
{ {
CSignedEncodeMsg_Close(msg); CSignedEncodeMsg_Close(msg);
......
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