Rob Shearman : wininet: HTTP_Connect should fail if a NULL or empty hostname is passed in.
Alexandre Julliard
julliard at winehq.org
Mon Feb 4 08:43:06 CST 2008
Module: wine
Branch: master
Commit: 59ab0cf362d764f978ab2c6d291b647e00a7c8ba
URL: http://source.winehq.org/git/wine.git/?a=commit;h=59ab0cf362d764f978ab2c6d291b647e00a7c8ba
Author: Rob Shearman <rob at codeweavers.com>
Date: Thu Jan 31 14:47:25 2008 +0000
wininet: HTTP_Connect should fail if a NULL or empty hostname is passed in.
Add tests for these circumstances.
---
dlls/wininet/http.c | 6 ++++++
dlls/wininet/tests/http.c | 12 +++++++++++-
2 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 16e1ec7..65b86fb 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -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));
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 457a65f..8bb7cca 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -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)
More information about the wine-cvs
mailing list