crypt32: Use assignment instead of memcpy to copy structs.

This commit is contained in:
Michael Stefaniuc 2013-02-05 13:22:27 +01:00 committed by Alexandre Julliard
parent 7d0ab835ae
commit 6af92365ea
4 changed files with 11 additions and 17 deletions

View file

@ -842,7 +842,7 @@ static BOOL container_matches_cert(PCCERT_CONTEXT pCert, LPCSTR container,
* keyProvInfo->pwszContainerName to be NULL or a heap-allocated container
* name.
*/
memcpy(&copy, keyProvInfo, sizeof(copy));
copy = *keyProvInfo;
copy.pwszContainerName = containerW;
matches = key_prov_info_matches_cert(pCert, &copy);
if (matches)
@ -2216,9 +2216,7 @@ BOOL WINAPI CryptSignAndEncodeCertificate(HCRYPTPROV_OR_NCRYPT_KEY_HANDLE hCrypt
info.ToBeSigned.cbData = encodedSize;
info.ToBeSigned.pbData = encoded;
memcpy(&info.SignatureAlgorithm,
pSignatureAlgorithm,
sizeof(info.SignatureAlgorithm));
info.SignatureAlgorithm = *pSignatureAlgorithm;
info.Signature.cbData = hashSize;
info.Signature.pbData = hash;
info.Signature.cUnusedBits = 0;
@ -2986,8 +2984,7 @@ static PCCERT_CONTEXT CRYPT_CreateSignedCert(const CRYPT_DER_BLOB *blob,
signedInfo.ToBeSigned.cbData = blob->cbData;
signedInfo.ToBeSigned.pbData = blob->pbData;
memcpy(&signedInfo.SignatureAlgorithm, sigAlgo,
sizeof(signedInfo.SignatureAlgorithm));
signedInfo.SignatureAlgorithm = *sigAlgo;
signedInfo.Signature.cbData = sigSize;
signedInfo.Signature.pbData = sig;
signedInfo.Signature.cUnusedBits = 0;
@ -3038,8 +3035,7 @@ static void CRYPT_MakeCertInfo(PCERT_INFO info, const CRYPT_DATA_BLOB *pSerialNu
info->SerialNumber.cbData = pSerialNumber->cbData;
info->SerialNumber.pbData = pSerialNumber->pbData;
if (pSignatureAlgorithm)
memcpy(&info->SignatureAlgorithm, pSignatureAlgorithm,
sizeof(info->SignatureAlgorithm));
info->SignatureAlgorithm = *pSignatureAlgorithm;
else
{
info->SignatureAlgorithm.pszObjId = oid;
@ -3066,8 +3062,7 @@ static void CRYPT_MakeCertInfo(PCERT_INFO info, const CRYPT_DATA_BLOB *pSerialNu
}
info->Subject.cbData = pSubjectIssuerBlob->cbData;
info->Subject.pbData = pSubjectIssuerBlob->pbData;
memcpy(&info->SubjectPublicKeyInfo, pubKey,
sizeof(info->SubjectPublicKeyInfo));
info->SubjectPublicKeyInfo = *pubKey;
if (pExtensions)
{
info->cExtension = pExtensions->cExtension;

View file

@ -285,8 +285,7 @@ BOOL WINAPI CryptHashMessage(PCRYPT_HASH_MESSAGE_PARA pHashPara,
memset(&info, 0, sizeof(info));
info.cbSize = sizeof(info);
info.hCryptProv = pHashPara->hCryptProv;
memcpy(&info.HashAlgorithm, &pHashPara->HashAlgorithm,
sizeof(info.HashAlgorithm));
info.HashAlgorithm = pHashPara->HashAlgorithm;
info.pvHashAuxInfo = pHashPara->pvHashAuxInfo;
msg = CryptMsgOpenToEncode(pHashPara->dwMsgEncodingType, flags, CMSG_HASHED,
&info, NULL, NULL);

View file

@ -652,21 +652,21 @@ static BOOL CRYPT_WriteSerializedStoreToStream(HCERTSTORE store,
ret = output(handle, fileHeader, sizeof(fileHeader));
if (ret)
{
memcpy(&interface, pCertInterface, sizeof(interface));
interface = *pCertInterface;
interface.serialize = (SerializeElementFunc)CRYPT_SerializeCertNoHash;
ret = CRYPT_SerializeContextsToStream(output, handle, &interface,
store);
}
if (ret)
{
memcpy(&interface, pCRLInterface, sizeof(interface));
interface = *pCRLInterface;
interface.serialize = (SerializeElementFunc)CRYPT_SerializeCRLNoHash;
ret = CRYPT_SerializeContextsToStream(output, handle, &interface,
store);
}
if (ret)
{
memcpy(&interface, pCTLInterface, sizeof(interface));
interface = *pCTLInterface;
interface.serialize = (SerializeElementFunc)CRYPT_SerializeCTLNoHash;
ret = CRYPT_SerializeContextsToStream(output, handle, &interface,
store);

View file

@ -181,12 +181,12 @@ static void test_verifyTimeValidity(void)
/* Check with 0 NotBefore and NotAfter */
ret = CertVerifyTimeValidity(&fileTime, &info);
ok(ret == 1, "Expected 1, got %d\n", ret);
memcpy(&info.NotAfter, &fileTime, sizeof(info.NotAfter));
info.NotAfter = fileTime;
/* Check with NotAfter equal to comparison time */
ret = CertVerifyTimeValidity(&fileTime, &info);
ok(ret == 0, "Expected 0, got %d\n", ret);
/* Check with NotBefore after comparison time */
memcpy(&info.NotBefore, &fileTime, sizeof(info.NotBefore));
info.NotBefore = fileTime;
info.NotBefore.dwLowDateTime += 5000;
ret = CertVerifyTimeValidity(&fileTime, &info);
ok(ret == -1, "Expected -1, got %d\n", ret);