Commit 59ab0cf3 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

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

Add tests for these circumstances.
parent b7f3ee51
......@@ -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));
......
......@@ -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)
......
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