Fixes a regression from 699e0a55ea71e2506917e38fc85cb4ae23a9cd1a, making "winetricks dotnet30sp1" fail.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49831 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/wintrust/crypt.c | 14 ++++++++++++-- dlls/wintrust/tests/crypt.c | 12 ++++++------ 2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/dlls/wintrust/crypt.c b/dlls/wintrust/crypt.c index be869ad8277..fcf419c76d1 100644 --- a/dlls/wintrust/crypt.c +++ b/dlls/wintrust/crypt.c @@ -908,6 +908,7 @@ HANDLE WINAPI CryptCATOpen(WCHAR *filename, DWORD flags, HCRYPTPROV hProv, BYTE *buffer = NULL; DWORD size, open_mode = OPEN_ALWAYS; struct cryptcat *cc; + BOOL valid;
TRACE("filename %s, flags %#x, provider %#lx, version %#x, type %#x\n", debugstr_w(filename), flags, hProv, dwPublicVersion, dwEncodingType); @@ -941,13 +942,15 @@ HANDLE WINAPI CryptCATOpen(WCHAR *filename, DWORD flags, HCRYPTPROV hProv, HeapFree(GetProcessHeap(), 0, buffer); return INVALID_HANDLE_VALUE; } - if (!ReadFile(file, buffer, size, &size, NULL) || !CryptMsgUpdate(hmsg, buffer, size, TRUE)) + if (!size) valid = FALSE; + else if (!ReadFile(file, buffer, size, &size, NULL)) { CloseHandle(file); HeapFree(GetProcessHeap(), 0, buffer); CryptMsgClose(hmsg); return INVALID_HANDLE_VALUE; } + else valid = CryptMsgUpdate(hmsg, buffer, size, TRUE); HeapFree(GetProcessHeap(), 0, buffer); CloseHandle(file);
@@ -961,7 +964,13 @@ HANDLE WINAPI CryptCATOpen(WCHAR *filename, DWORD flags, HCRYPTPROV hProv,
cc->msg = hmsg; cc->encoding = dwEncodingType; - if (CryptMsgGetParam(hmsg, CMSG_ATTR_CERT_COUNT_PARAM, 0, &cc->attr_count, &size)) + if (!valid) + { + cc->magic = CRYPTCAT_MAGIC; + SetLastError(ERROR_SUCCESS); + return cc; + } + else if (CryptMsgGetParam(hmsg, CMSG_ATTR_CERT_COUNT_PARAM, 0, &cc->attr_count, &size)) { DWORD i, sum = 0; BYTE *p; @@ -1012,6 +1021,7 @@ HANDLE WINAPI CryptCATOpen(WCHAR *filename, DWORD flags, HCRYPTPROV hProv, return INVALID_HANDLE_VALUE; } cc->magic = CRYPTCAT_MAGIC; + SetLastError(ERROR_SUCCESS); return cc; } HeapFree(GetProcessHeap(), 0, cc); diff --git a/dlls/wintrust/tests/crypt.c b/dlls/wintrust/tests/crypt.c index 1b436e9f4ab..5f9c402e00f 100644 --- a/dlls/wintrust/tests/crypt.c +++ b/dlls/wintrust/tests/crypt.c @@ -429,10 +429,10 @@ static void test_CryptCATOpen(void) } else { - todo_wine ok(cat != INVALID_HANDLE_VALUE, "flags %#x: expected success\n", flags); - todo_wine ok(!GetLastError(), "flags %#x: got error %u\n", flags, GetLastError()); + ok(cat != INVALID_HANDLE_VALUE, "flags %#x: expected success\n", flags); + ok(!GetLastError(), "flags %#x: got error %u\n", flags, GetLastError()); ret = pCryptCATClose(cat); - todo_wine ok(ret, "flags %#x: failed to close file\n", flags); + ok(ret, "flags %#x: failed to close file\n", flags); ret = DeleteFileW(filename); ok(ret, "flags %#x: failed to delete file, error %u\n", flags, GetLastError()); } @@ -443,10 +443,10 @@ static void test_CryptCATOpen(void)
SetLastError(0xdeadbeef); cat = pCryptCATOpen(filename, flags, 0, 0, 0); - todo_wine ok(cat != INVALID_HANDLE_VALUE, "flags %#x: expected success\n", flags); - todo_wine ok(!GetLastError(), "flags %#x: got error %u\n", flags, GetLastError()); + ok(cat != INVALID_HANDLE_VALUE, "flags %#x: expected success\n", flags); + ok(!GetLastError(), "flags %#x: got error %u\n", flags, GetLastError()); ret = pCryptCATClose(cat); - todo_wine ok(ret, "flags %#x: failed to close file\n", flags); + ok(ret, "flags %#x: failed to close file\n", flags);
file = _wfopen(filename, L"r"); ret = fread(buffer, 1, sizeof(buffer), file);