[PATCH 2/3] wintrust: Allocate CryptCATOpen objects before reading the file.

Rémi Bernon rbernon at codeweavers.com
Wed Dec 16 07:41:41 CST 2020


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/wintrust/crypt.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/dlls/wintrust/crypt.c b/dlls/wintrust/crypt.c
index 4fbf75f7e0c..e9a58a84ac4 100644
--- a/dlls/wintrust/crypt.c
+++ b/dlls/wintrust/crypt.c
@@ -928,16 +928,16 @@ HANDLE WINAPI CryptCATOpen(WCHAR *filename, DWORD flags, HCRYPTPROV hProv,
     file = CreateFileW(filename, GENERIC_READ, FILE_SHARE_READ, NULL, open_mode, 0, NULL);
     if (file == INVALID_HANDLE_VALUE) return INVALID_HANDLE_VALUE;
 
+    if (!(hmsg = CryptMsgOpenToDecode(dwEncodingType, 0, 0, hProv, NULL, NULL))) goto failed;
+    if (!(cc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cc)))) goto failed_alloc;
+    cc->msg = hmsg;
+    cc->encoding = dwEncodingType;
+
     size = GetFileSize(file, NULL);
     if (!(buffer = HeapAlloc(GetProcessHeap(), 0, size))) goto failed_alloc;
-    if (!(hmsg = CryptMsgOpenToDecode(dwEncodingType, 0, 0, hProv, NULL, NULL))) goto failed;
     if (!ReadFile(file, buffer, size, &size, NULL) || !CryptMsgUpdate(hmsg, buffer, size, TRUE)) goto failed;
 
     size = sizeof(DWORD);
-    if (!(cc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cc)))) goto failed_alloc;
-
-    cc->msg = hmsg;
-    cc->encoding = dwEncodingType;
     if (!CryptMsgGetParam(hmsg, CMSG_ATTR_CERT_COUNT_PARAM, 0, &cc->attr_count, &size)) goto failed;
 
     for (i = 0; i < cc->attr_count; i++)
-- 
2.29.2




More information about the wine-devel mailing list