Commit 0c75ead3 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

wininet: Validate parameters passed to RetrieveUrlCacheEntryInfoA/W.

Add tests for this.
parent 31d6dbfd
......@@ -113,6 +113,7 @@ static void test_GetUrlCacheEntryInfoExA(void)
check_cache_entry_infoA("GetUrlCacheEntryInfoEx", lpCacheEntryInfo);
cbCacheEntryInfo = 100000;
SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
......@@ -120,6 +121,29 @@ static void test_GetUrlCacheEntryInfoExA(void)
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
}
static void test_RetrieveUrlCacheEntryA(void)
{
BOOL ret;
DWORD cbCacheEntryInfo;
cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef);
ret = RetrieveUrlCacheEntryFile(NULL, NULL, &cbCacheEntryInfo, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
SetLastError(0xdeadbeef);
ret = RetrieveUrlCacheEntryFile(TEST_URL, NULL, NULL, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
SetLastError(0xdeadbeef);
cbCacheEntryInfo = 100000;
ret = RetrieveUrlCacheEntryFile(NULL, NULL, &cbCacheEntryInfo, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
}
static void test_urlcacheA(void)
{
BOOL ret;
......@@ -168,6 +192,7 @@ static void test_urlcacheA(void)
test_find_url_cache_entriesA();
test_GetUrlCacheEntryInfoExA();
test_RetrieveUrlCacheEntryA();
if (pDeleteUrlCacheEntryA)
{
......
......@@ -1817,6 +1817,13 @@ BOOL WINAPI RetrieveUrlCacheEntryFileA(
lpdwCacheEntryInfoBufferSize,
dwReserved);
if (!lpszUrlName || !lpdwCacheEntryInfoBufferSize ||
(!lpCacheEntryInfo && *lpdwCacheEntryInfoBufferSize))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
error = URLCacheContainers_FindContainerA(lpszUrlName, &pContainer);
if (error != ERROR_SUCCESS)
{
......@@ -1899,6 +1906,13 @@ BOOL WINAPI RetrieveUrlCacheEntryFileW(
lpdwCacheEntryInfoBufferSize,
dwReserved);
if (!lpszUrlName || !lpdwCacheEntryInfoBufferSize ||
(!lpCacheEntryInfo && *lpdwCacheEntryInfoBufferSize))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
error = URLCacheContainers_FindContainerW(lpszUrlName, &pContainer);
if (error != ERROR_SUCCESS)
{
......
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