wintrust: Don't fail CryptCATOpen on empty file or invalid data.
Fixes a regression from 699e0a55ea
,
making "winetricks dotnet30sp1" fail.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49831
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
afac4f09c7
commit
0fb7ea9120
|
@ -908,6 +908,7 @@ HANDLE WINAPI CryptCATOpen(WCHAR *filename, DWORD flags, HCRYPTPROV hProv,
|
||||||
BYTE *buffer = NULL;
|
BYTE *buffer = NULL;
|
||||||
DWORD size, open_mode = OPEN_ALWAYS;
|
DWORD size, open_mode = OPEN_ALWAYS;
|
||||||
struct cryptcat *cc;
|
struct cryptcat *cc;
|
||||||
|
BOOL valid;
|
||||||
|
|
||||||
TRACE("filename %s, flags %#x, provider %#lx, version %#x, type %#x\n",
|
TRACE("filename %s, flags %#x, provider %#lx, version %#x, type %#x\n",
|
||||||
debugstr_w(filename), flags, hProv, dwPublicVersion, dwEncodingType);
|
debugstr_w(filename), flags, hProv, dwPublicVersion, dwEncodingType);
|
||||||
|
@ -941,13 +942,15 @@ HANDLE WINAPI CryptCATOpen(WCHAR *filename, DWORD flags, HCRYPTPROV hProv,
|
||||||
HeapFree(GetProcessHeap(), 0, buffer);
|
HeapFree(GetProcessHeap(), 0, buffer);
|
||||||
return INVALID_HANDLE_VALUE;
|
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);
|
CloseHandle(file);
|
||||||
HeapFree(GetProcessHeap(), 0, buffer);
|
HeapFree(GetProcessHeap(), 0, buffer);
|
||||||
CryptMsgClose(hmsg);
|
CryptMsgClose(hmsg);
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
else valid = CryptMsgUpdate(hmsg, buffer, size, TRUE);
|
||||||
HeapFree(GetProcessHeap(), 0, buffer);
|
HeapFree(GetProcessHeap(), 0, buffer);
|
||||||
CloseHandle(file);
|
CloseHandle(file);
|
||||||
|
|
||||||
|
@ -961,7 +964,13 @@ HANDLE WINAPI CryptCATOpen(WCHAR *filename, DWORD flags, HCRYPTPROV hProv,
|
||||||
|
|
||||||
cc->msg = hmsg;
|
cc->msg = hmsg;
|
||||||
cc->encoding = dwEncodingType;
|
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;
|
DWORD i, sum = 0;
|
||||||
BYTE *p;
|
BYTE *p;
|
||||||
|
@ -1012,6 +1021,7 @@ HANDLE WINAPI CryptCATOpen(WCHAR *filename, DWORD flags, HCRYPTPROV hProv,
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
cc->magic = CRYPTCAT_MAGIC;
|
cc->magic = CRYPTCAT_MAGIC;
|
||||||
|
SetLastError(ERROR_SUCCESS);
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
HeapFree(GetProcessHeap(), 0, cc);
|
HeapFree(GetProcessHeap(), 0, cc);
|
||||||
|
|
|
@ -429,10 +429,10 @@ static void test_CryptCATOpen(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
todo_wine ok(cat != INVALID_HANDLE_VALUE, "flags %#x: expected success\n", flags);
|
ok(cat != INVALID_HANDLE_VALUE, "flags %#x: expected success\n", flags);
|
||||||
todo_wine ok(!GetLastError(), "flags %#x: got error %u\n", flags, GetLastError());
|
ok(!GetLastError(), "flags %#x: got error %u\n", flags, GetLastError());
|
||||||
ret = pCryptCATClose(cat);
|
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);
|
ret = DeleteFileW(filename);
|
||||||
ok(ret, "flags %#x: failed to delete file, error %u\n", flags, GetLastError());
|
ok(ret, "flags %#x: failed to delete file, error %u\n", flags, GetLastError());
|
||||||
}
|
}
|
||||||
|
@ -443,10 +443,10 @@ static void test_CryptCATOpen(void)
|
||||||
|
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
cat = pCryptCATOpen(filename, flags, 0, 0, 0);
|
cat = pCryptCATOpen(filename, flags, 0, 0, 0);
|
||||||
todo_wine ok(cat != INVALID_HANDLE_VALUE, "flags %#x: expected success\n", flags);
|
ok(cat != INVALID_HANDLE_VALUE, "flags %#x: expected success\n", flags);
|
||||||
todo_wine ok(!GetLastError(), "flags %#x: got error %u\n", flags, GetLastError());
|
ok(!GetLastError(), "flags %#x: got error %u\n", flags, GetLastError());
|
||||||
ret = pCryptCATClose(cat);
|
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");
|
file = _wfopen(filename, L"r");
|
||||||
ret = fread(buffer, 1, sizeof(buffer), file);
|
ret = fread(buffer, 1, sizeof(buffer), file);
|
||||||
|
|
Loading…
Reference in New Issue