Commit 4f893215 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

cryptnet: Lock cache file while accessing it.

parent 81e48cd0
...@@ -503,24 +503,26 @@ static BOOL CRYPT_GetObjectFromCache(LPCWSTR pszURL, PCRYPT_BLOB_ARRAY pObject, ...@@ -503,24 +503,26 @@ static BOOL CRYPT_GetObjectFromCache(LPCWSTR pszURL, PCRYPT_BLOB_ARRAY pObject,
TRACE("(%s, %p, %p)\n", debugstr_w(pszURL), pObject, pAuxInfo); TRACE("(%s, %p, %p)\n", debugstr_w(pszURL), pObject, pAuxInfo);
ret = GetUrlCacheEntryInfoW(pszURL, NULL, &size); RetrieveUrlCacheEntryFileW(pszURL, NULL, &size, 0);
if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER) if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
return FALSE;
pCacheInfo = CryptMemAlloc(size);
if (!pCacheInfo)
{ {
pCacheInfo = CryptMemAlloc(size); SetLastError(ERROR_OUTOFMEMORY);
if (pCacheInfo) return FALSE;
ret = TRUE;
else
SetLastError(ERROR_OUTOFMEMORY);
} }
if (ret && (ret = GetUrlCacheEntryInfoW(pszURL, pCacheInfo, &size)))
if ((ret = RetrieveUrlCacheEntryFileW(pszURL, pCacheInfo, &size, 0)))
{ {
FILETIME ft; FILETIME ft;
GetSystemTimeAsFileTime(&ft); GetSystemTimeAsFileTime(&ft);
if (CompareFileTime(&pCacheInfo->ExpireTime, &ft) >= 0) if (CompareFileTime(&pCacheInfo->ExpireTime, &ft) >= 0)
{ {
HANDLE hFile = CreateFileW(pCacheInfo->lpszLocalFileName, HANDLE hFile = CreateFileW(pCacheInfo->lpszLocalFileName, GENERIC_READ,
GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE) if (hFile != INVALID_HANDLE_VALUE)
{ {
...@@ -547,6 +549,7 @@ static BOOL CRYPT_GetObjectFromCache(LPCWSTR pszURL, PCRYPT_BLOB_ARRAY pObject, ...@@ -547,6 +549,7 @@ static BOOL CRYPT_GetObjectFromCache(LPCWSTR pszURL, PCRYPT_BLOB_ARRAY pObject,
DeleteUrlCacheEntryW(pszURL); DeleteUrlCacheEntryW(pszURL);
ret = FALSE; ret = FALSE;
} }
UnlockUrlCacheEntryFileW(pszURL, 0);
} }
CryptMemFree(pCacheInfo); CryptMemFree(pCacheInfo);
TRACE("returning %d\n", ret); TRACE("returning %d\n", ret);
......
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