Commit 42a86138 authored by Alexandre Julliard's avatar Alexandre Julliard

wintrust/tests: Use nameless unions/structs.

parent 30ee1d10
...@@ -143,7 +143,7 @@ static void test_encodeSPCLink(void) ...@@ -143,7 +143,7 @@ static void test_encodeSPCLink(void)
LocalFree(buf); LocalFree(buf);
} }
/* With an invalid char: */ /* With an invalid char: */
U(link).pwszUrl = (LPWSTR)nihongoURL; link.pwszUrl = (LPWSTR)nihongoURL;
size = 1; size = 1;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link, ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link,
...@@ -156,7 +156,7 @@ static void test_encodeSPCLink(void) ...@@ -156,7 +156,7 @@ static void test_encodeSPCLink(void)
* index of the first invalid character. * index of the first invalid character.
*/ */
ok(size == 0, "Expected size 0, got %ld\n", size); ok(size == 0, "Expected size 0, got %ld\n", size);
U(link).pwszUrl = url; link.pwszUrl = url;
ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link, ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
...@@ -167,7 +167,7 @@ static void test_encodeSPCLink(void) ...@@ -167,7 +167,7 @@ static void test_encodeSPCLink(void)
LocalFree(buf); LocalFree(buf);
} }
link.dwLinkChoice = SPC_FILE_LINK_CHOICE; link.dwLinkChoice = SPC_FILE_LINK_CHOICE;
U(link).pwszFile = (LPWSTR)nihongoURL; link.pwszFile = (LPWSTR)nihongoURL;
ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link, ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
...@@ -178,7 +178,7 @@ static void test_encodeSPCLink(void) ...@@ -178,7 +178,7 @@ static void test_encodeSPCLink(void)
LocalFree(buf); LocalFree(buf);
} }
link.dwLinkChoice = SPC_MONIKER_LINK_CHOICE; link.dwLinkChoice = SPC_MONIKER_LINK_CHOICE;
memset(&U(link).Moniker, 0, sizeof(U(link).Moniker)); memset(&link.Moniker, 0, sizeof(link.Moniker));
ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link, ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
...@@ -188,9 +188,9 @@ static void test_encodeSPCLink(void) ...@@ -188,9 +188,9 @@ static void test_encodeSPCLink(void)
ok(!memcmp(buf, emptyMonikerSPCLink, size), "Unexpected value\n"); ok(!memcmp(buf, emptyMonikerSPCLink, size), "Unexpected value\n");
LocalFree(buf); LocalFree(buf);
} }
memset(&U(link).Moniker.ClassId, 0xea, sizeof(U(link).Moniker.ClassId)); memset(&link.Moniker.ClassId, 0xea, sizeof(link.Moniker.ClassId));
U(link).Moniker.SerializedData.pbData = data; link.Moniker.SerializedData.pbData = data;
U(link).Moniker.SerializedData.cbData = sizeof(data); link.Moniker.SerializedData.cbData = sizeof(data);
ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link, ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, &link,
CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
...@@ -228,7 +228,7 @@ static void test_decodeSPCLink(void) ...@@ -228,7 +228,7 @@ static void test_decodeSPCLink(void)
link = (SPC_LINK *)buf; link = (SPC_LINK *)buf;
ok(link->dwLinkChoice == SPC_URL_LINK_CHOICE, ok(link->dwLinkChoice == SPC_URL_LINK_CHOICE,
"Expected SPC_URL_LINK_CHOICE, got %ld\n", link->dwLinkChoice); "Expected SPC_URL_LINK_CHOICE, got %ld\n", link->dwLinkChoice);
ok(lstrlenW(U(*link).pwszUrl) == 0, "Expected empty string\n"); ok(lstrlenW(link->pwszUrl) == 0, "Expected empty string\n");
LocalFree(buf); LocalFree(buf);
} }
ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT,
...@@ -240,7 +240,7 @@ static void test_decodeSPCLink(void) ...@@ -240,7 +240,7 @@ static void test_decodeSPCLink(void)
link = (SPC_LINK *)buf; link = (SPC_LINK *)buf;
ok(link->dwLinkChoice == SPC_URL_LINK_CHOICE, ok(link->dwLinkChoice == SPC_URL_LINK_CHOICE,
"Expected SPC_URL_LINK_CHOICE, got %ld\n", link->dwLinkChoice); "Expected SPC_URL_LINK_CHOICE, got %ld\n", link->dwLinkChoice);
ok(!lstrcmpW(U(*link).pwszUrl, url), "Unexpected URL\n"); ok(!lstrcmpW(link->pwszUrl, url), "Unexpected URL\n");
LocalFree(buf); LocalFree(buf);
} }
ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT,
...@@ -252,7 +252,7 @@ static void test_decodeSPCLink(void) ...@@ -252,7 +252,7 @@ static void test_decodeSPCLink(void)
link = (SPC_LINK *)buf; link = (SPC_LINK *)buf;
ok(link->dwLinkChoice == SPC_FILE_LINK_CHOICE, ok(link->dwLinkChoice == SPC_FILE_LINK_CHOICE,
"Expected SPC_FILE_LINK_CHOICE, got %ld\n", link->dwLinkChoice); "Expected SPC_FILE_LINK_CHOICE, got %ld\n", link->dwLinkChoice);
ok(!lstrcmpW(U(*link).pwszFile, nihongoURL), "Unexpected file\n"); ok(!lstrcmpW(link->pwszFile, nihongoURL), "Unexpected file\n");
LocalFree(buf); LocalFree(buf);
} }
ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT, ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, SPC_LINK_STRUCT,
...@@ -266,9 +266,9 @@ static void test_decodeSPCLink(void) ...@@ -266,9 +266,9 @@ static void test_decodeSPCLink(void)
link = (SPC_LINK *)buf; link = (SPC_LINK *)buf;
ok(link->dwLinkChoice == SPC_MONIKER_LINK_CHOICE, ok(link->dwLinkChoice == SPC_MONIKER_LINK_CHOICE,
"Expected SPC_MONIKER_LINK_CHOICE, got %ld\n", link->dwLinkChoice); "Expected SPC_MONIKER_LINK_CHOICE, got %ld\n", link->dwLinkChoice);
ok(!memcmp(&U(*link).Moniker.ClassId, &emptyMoniker.ClassId, ok(!memcmp(&link->Moniker.ClassId, &emptyMoniker.ClassId,
sizeof(emptyMoniker.ClassId)), "Unexpected value\n"); sizeof(emptyMoniker.ClassId)), "Unexpected value\n");
ok(U(*link).Moniker.SerializedData.cbData == 0, ok(link->Moniker.SerializedData.cbData == 0,
"Expected no serialized data\n"); "Expected no serialized data\n");
LocalFree(buf); LocalFree(buf);
} }
...@@ -284,11 +284,11 @@ static void test_decodeSPCLink(void) ...@@ -284,11 +284,11 @@ static void test_decodeSPCLink(void)
ok(link->dwLinkChoice == SPC_MONIKER_LINK_CHOICE, ok(link->dwLinkChoice == SPC_MONIKER_LINK_CHOICE,
"Expected SPC_MONIKER_LINK_CHOICE, got %ld\n", link->dwLinkChoice); "Expected SPC_MONIKER_LINK_CHOICE, got %ld\n", link->dwLinkChoice);
memset(&id, 0xea, sizeof(id)); memset(&id, 0xea, sizeof(id));
ok(!memcmp(&U(*link).Moniker.ClassId, &id, sizeof(id)), ok(!memcmp(&link->Moniker.ClassId, &id, sizeof(id)),
"Unexpected value\n"); "Unexpected value\n");
ok(U(*link).Moniker.SerializedData.cbData == sizeof(data), ok(link->Moniker.SerializedData.cbData == sizeof(data),
"Unexpected data size %ld\n", U(*link).Moniker.SerializedData.cbData); "Unexpected data size %ld\n", link->Moniker.SerializedData.cbData);
ok(!memcmp(U(*link).Moniker.SerializedData.pbData, data, sizeof(data)), ok(!memcmp(link->Moniker.SerializedData.pbData, data, sizeof(data)),
"Unexpected value\n"); "Unexpected value\n");
LocalFree(buf); LocalFree(buf);
} }
...@@ -405,7 +405,7 @@ static void test_encodeSPCPEImage(void) ...@@ -405,7 +405,7 @@ static void test_encodeSPCPEImage(void)
LocalFree(buf); LocalFree(buf);
} }
/* Finally, a non-empty file: */ /* Finally, a non-empty file: */
U(link).pwszFile = (LPWSTR)nihongoURL; link.pwszFile = (LPWSTR)nihongoURL;
ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT, ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_PE_IMAGE_DATA_STRUCT,
&imageData, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); &imageData, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
...@@ -474,7 +474,7 @@ static void test_decodeSPCPEImage(void) ...@@ -474,7 +474,7 @@ static void test_decodeSPCPEImage(void)
ok(imageData->pFile->dwLinkChoice == SPC_FILE_LINK_CHOICE, ok(imageData->pFile->dwLinkChoice == SPC_FILE_LINK_CHOICE,
"Expected SPC_FILE_LINK_CHOICE, got %ld\n", "Expected SPC_FILE_LINK_CHOICE, got %ld\n",
imageData->pFile->dwLinkChoice); imageData->pFile->dwLinkChoice);
ok(!lstrcmpW(U(*imageData->pFile).pwszFile, emptyString), ok(!lstrcmpW(imageData->pFile->pwszFile, emptyString),
"Unexpected file\n"); "Unexpected file\n");
} }
LocalFree(buf); LocalFree(buf);
...@@ -497,7 +497,7 @@ static void test_decodeSPCPEImage(void) ...@@ -497,7 +497,7 @@ static void test_decodeSPCPEImage(void)
ok(imageData->pFile->dwLinkChoice == SPC_FILE_LINK_CHOICE, ok(imageData->pFile->dwLinkChoice == SPC_FILE_LINK_CHOICE,
"Expected SPC_FILE_LINK_CHOICE, got %ld\n", "Expected SPC_FILE_LINK_CHOICE, got %ld\n",
imageData->pFile->dwLinkChoice); imageData->pFile->dwLinkChoice);
ok(!lstrcmpW(U(*imageData->pFile).pwszFile, emptyString), ok(!lstrcmpW(imageData->pFile->pwszFile, emptyString),
"Unexpected file\n"); "Unexpected file\n");
} }
LocalFree(buf); LocalFree(buf);
...@@ -520,7 +520,7 @@ static void test_decodeSPCPEImage(void) ...@@ -520,7 +520,7 @@ static void test_decodeSPCPEImage(void)
ok(imageData->pFile->dwLinkChoice == SPC_FILE_LINK_CHOICE, ok(imageData->pFile->dwLinkChoice == SPC_FILE_LINK_CHOICE,
"Expected SPC_FILE_LINK_CHOICE, got %ld\n", "Expected SPC_FILE_LINK_CHOICE, got %ld\n",
imageData->pFile->dwLinkChoice); imageData->pFile->dwLinkChoice);
ok(!lstrcmpW(U(*imageData->pFile).pwszFile, nihongoURL), ok(!lstrcmpW(imageData->pFile->pwszFile, nihongoURL),
"Unexpected file\n"); "Unexpected file\n");
} }
LocalFree(buf); LocalFree(buf);
...@@ -840,7 +840,7 @@ static void test_encodeSpOpusInfo(void) ...@@ -840,7 +840,7 @@ static void test_encodeSpOpusInfo(void)
ok(!ret && GetLastError() == E_INVALIDARG, ok(!ret && GetLastError() == E_INVALIDARG,
"expected E_INVALIDARG, got %08lx\n", GetLastError()); "expected E_INVALIDARG, got %08lx\n", GetLastError());
moreInfo.dwLinkChoice = SPC_URL_LINK_CHOICE; moreInfo.dwLinkChoice = SPC_URL_LINK_CHOICE;
U(moreInfo).pwszUrl = winehq; moreInfo.pwszUrl = winehq;
ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT, ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
&info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); &info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError()); ok(ret, "CryptEncodeObjectEx failed: %08lx\n", GetLastError());
...@@ -908,7 +908,7 @@ static void test_decodeSpOpusInfo(void) ...@@ -908,7 +908,7 @@ static void test_decodeSpOpusInfo(void)
{ {
ok(info->pMoreInfo->dwLinkChoice == SPC_URL_LINK_CHOICE, ok(info->pMoreInfo->dwLinkChoice == SPC_URL_LINK_CHOICE,
"unexpected link choice %ld\n", info->pMoreInfo->dwLinkChoice); "unexpected link choice %ld\n", info->pMoreInfo->dwLinkChoice);
ok(!lstrcmpW(U(*info->pMoreInfo).pwszUrl, winehq), ok(!lstrcmpW(info->pMoreInfo->pwszUrl, winehq),
"unexpected link value\n"); "unexpected link value\n");
} }
ok(!info->pPublisherInfo, "expected NULL\n"); ok(!info->pPublisherInfo, "expected NULL\n");
...@@ -929,7 +929,7 @@ static void test_decodeSpOpusInfo(void) ...@@ -929,7 +929,7 @@ static void test_decodeSpOpusInfo(void)
ok(info->pPublisherInfo->dwLinkChoice == SPC_URL_LINK_CHOICE, ok(info->pPublisherInfo->dwLinkChoice == SPC_URL_LINK_CHOICE,
"unexpected link choice %ld\n", "unexpected link choice %ld\n",
info->pPublisherInfo->dwLinkChoice); info->pPublisherInfo->dwLinkChoice);
ok(!lstrcmpW(U(*info->pPublisherInfo).pwszUrl, winehq), ok(!lstrcmpW(info->pPublisherInfo->pwszUrl, winehq),
"unexpected link value\n"); "unexpected link value\n");
} }
LocalFree(info); LocalFree(info);
......
...@@ -338,7 +338,7 @@ static void testObjTrust(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID) ...@@ -338,7 +338,7 @@ static void testObjTrust(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID)
ERROR_INVALID_PARAMETER, ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %08lx\n", "Expected ERROR_INVALID_PARAMETER, got %08lx\n",
data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]); data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
U(wintrust_data).pCert = &certInfo; wintrust_data.pCert = &certInfo;
wintrust_data.dwUnionChoice = WTD_CHOICE_CERT; wintrust_data.dwUnionChoice = WTD_CHOICE_CERT;
ret = funcs->pfnObjectTrust(&data); ret = funcs->pfnObjectTrust(&data);
ok(ret == S_OK, "Expected S_OK, got %08lx\n", ret); ok(ret == S_OK, "Expected S_OK, got %08lx\n", ret);
...@@ -349,21 +349,21 @@ static void testObjTrust(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID) ...@@ -349,21 +349,21 @@ static void testObjTrust(SAFE_PROVIDER_FUNCTIONS *funcs, GUID *actionID)
CertFreeCertificateContext(certInfo.psCertContext); CertFreeCertificateContext(certInfo.psCertContext);
certInfo.psCertContext = NULL; certInfo.psCertContext = NULL;
wintrust_data.dwUnionChoice = WTD_CHOICE_FILE; wintrust_data.dwUnionChoice = WTD_CHOICE_FILE;
U(wintrust_data).pFile = NULL; wintrust_data.pFile = NULL;
ret = funcs->pfnObjectTrust(&data); ret = funcs->pfnObjectTrust(&data);
ok(ret == S_FALSE, "Expected S_FALSE, got %08lx\n", ret); ok(ret == S_FALSE, "Expected S_FALSE, got %08lx\n", ret);
ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] == ok(data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV] ==
ERROR_INVALID_PARAMETER, ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %08lx\n", "Expected ERROR_INVALID_PARAMETER, got %08lx\n",
data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]); data.padwTrustStepErrors[TRUSTERROR_STEP_FINAL_OBJPROV]);
U(wintrust_data).pFile = &fileInfo; wintrust_data.pFile = &fileInfo;
/* Crashes /* Crashes
ret = funcs->pfnObjectTrust(&data); ret = funcs->pfnObjectTrust(&data);
*/ */
/* Create and test with an empty file */ /* Create and test with an empty file */
fileInfo.hFile = create_temp_file(pathW); fileInfo.hFile = create_temp_file(pathW);
/* pfnObjectTrust now crashes unless both pPDSip and psPfns are set */ /* pfnObjectTrust now crashes unless both pPDSip and psPfns are set */
U(data).pPDSip = &provDataSIP; data.pPDSip = &provDataSIP;
data.psPfns = (CRYPT_PROVIDER_FUNCTIONS *)funcs; data.psPfns = (CRYPT_PROVIDER_FUNCTIONS *)funcs;
ret = funcs->pfnObjectTrust(&data); ret = funcs->pfnObjectTrust(&data);
ok(ret == S_FALSE, "Expected S_FALSE, got %08lx\n", ret); ok(ret == S_FALSE, "Expected S_FALSE, got %08lx\n", ret);
...@@ -838,7 +838,7 @@ static void test_wintrust(void) ...@@ -838,7 +838,7 @@ static void test_wintrust(void)
wtd.dwUIChoice = WTD_UI_NONE; wtd.dwUIChoice = WTD_UI_NONE;
wtd.fdwRevocationChecks = WTD_REVOKE_WHOLECHAIN; wtd.fdwRevocationChecks = WTD_REVOKE_WHOLECHAIN;
wtd.dwUnionChoice = WTD_CHOICE_FILE; wtd.dwUnionChoice = WTD_CHOICE_FILE;
U(wtd).pFile = &file; wtd.pFile = &file;
wtd.dwStateAction = WTD_STATEACTION_VERIFY; wtd.dwStateAction = WTD_STATEACTION_VERIFY;
memset(&file, 0, sizeof(file)); memset(&file, 0, sizeof(file));
file.cbStruct = sizeof(file); file.cbStruct = sizeof(file);
......
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