wininet: HTTP_Connect should fail if a NULL or empty hostname is passed in.

Add tests for these circumstances.
This commit is contained in:
Rob Shearman 2008-01-31 14:47:25 +00:00 committed by Alexandre Julliard
parent b7f3ee51b1
commit 59ab0cf362
2 changed files with 17 additions and 1 deletions

View File

@ -2795,6 +2795,12 @@ HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
TRACE("-->\n");
if (!lpszServerName || !lpszServerName[0])
{
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
goto lerror;
}
assert( hIC->hdr.htype == WH_HINIT );
lpwhs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPSESSIONW));

View File

@ -929,9 +929,19 @@ static void InternetOpenRequest_test(void)
session = InternetOpenA("Wine Regression Test", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
ok(session != NULL ,"Unable to open Internet session\n");
connect = InternetConnectA(session, NULL, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL,
INTERNET_SERVICE_HTTP, 0, 0);
ok(connect == NULL, "InternetConnectA should have failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "InternetConnectA with NULL server named should have failed with ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
connect = InternetConnectA(session, "", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL,
INTERNET_SERVICE_HTTP, 0, 0);
ok(connect == NULL, "InternetConnectA should have failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "InternetConnectA with blank server named should have failed with ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
connect = InternetConnectA(session, "winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL,
INTERNET_SERVICE_HTTP, 0, 0);
ok(connect != NULL, "Unable to connect to http://winehq.org\n");
ok(connect != NULL, "Unable to connect to http://winehq.org with error %d\n", GetLastError());
request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, types, INTERNET_FLAG_NO_CACHE_WRITE, 0);
if (!request && GetLastError() == ERROR_INTERNET_NAME_NOT_RESOLVED)