crypt32: Make helper for copying CMSG_CMS_SIGNER_INFO attributes more generic.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2020-11-12 11:15:01 +03:00 committed by Alexandre Julliard
parent 1864043549
commit 1b87f222ed
1 changed files with 6 additions and 11 deletions

View File

@ -2995,15 +2995,14 @@ static BOOL CDecodeEnvelopedMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType,
return ret; return ret;
} }
static BOOL CRYPT_CopyUnauthAttr(void *pvData, DWORD *pcbData, static BOOL CRYPT_CopyAttr(void *pvData, DWORD *pcbData, const CRYPT_ATTRIBUTES *attr)
const CMSG_CMS_SIGNER_INFO *in)
{ {
DWORD size; DWORD size;
BOOL ret; BOOL ret;
TRACE("(%p, %d, %p)\n", pvData, pvData ? *pcbData : 0, in); TRACE("(%p, %d, %p)\n", pvData, pvData ? *pcbData : 0, attr);
size = CRYPT_SizeOfAttributes(&in->UnauthAttrs); size = CRYPT_SizeOfAttributes(attr);
if (!pvData) if (!pvData)
{ {
*pcbData = size; *pcbData = size;
@ -3016,12 +3015,8 @@ static BOOL CRYPT_CopyUnauthAttr(void *pvData, DWORD *pcbData,
ret = FALSE; ret = FALSE;
} }
else else
{ ret = CRYPT_ConstructAttributes(pvData, attr);
CRYPT_ATTRIBUTES *out = pvData;
CRYPT_ConstructAttributes(out,&in->UnauthAttrs);
ret = TRUE;
}
TRACE("returning %d\n", ret); TRACE("returning %d\n", ret);
return ret; return ret;
} }
@ -3205,8 +3200,8 @@ static BOOL CDecodeSignedMsg_GetParam(CDecodeMsg *msg, DWORD dwParamType,
if (dwIndex >= msg->u.signed_data.info->cSignerInfo) if (dwIndex >= msg->u.signed_data.info->cSignerInfo)
SetLastError(CRYPT_E_INVALID_INDEX); SetLastError(CRYPT_E_INVALID_INDEX);
else else
ret = CRYPT_CopyUnauthAttr(pvData, pcbData, ret = CRYPT_CopyAttr(pvData, pcbData,
&msg->u.signed_data.info->rgSignerInfo[dwIndex]); &msg->u.signed_data.info->rgSignerInfo[dwIndex].UnauthAttrs);
} }
else else
SetLastError(CRYPT_E_INVALID_MSG_TYPE); SetLastError(CRYPT_E_INVALID_MSG_TYPE);