wininet: Treat an empty username as NULL in FTP_Connect().
Henri Verbeet
hverbeet at codeweavers.com
Tue Nov 18 02:27:59 CST 2008
---
dlls/wininet/ftp.c | 4 ++--
dlls/wininet/tests/ftp.c | 23 +++++++++++++++++++++++
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index cb24782..9ad34df 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -2256,7 +2256,7 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
assert( hIC->hdr.htype == WH_HINIT );
- if (NULL == lpszUserName && NULL != lpszPassword)
+ if ((!lpszUserName || !strlenW(lpszUserName)) && lpszPassword)
{
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
goto lerror;
@@ -2302,7 +2302,7 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
if(hIC->lpszProxyBypass)
FIXME("Proxy bypass is ignored.\n");
}
- if ( !lpszUserName) {
+ if (!lpszUserName || !strlenW(lpszUserName)) {
HKEY key;
WCHAR szPassword[MAX_PATH];
DWORD len = sizeof(szPassword);
diff --git a/dlls/wininet/tests/ftp.c b/dlls/wininet/tests/ftp.c
index 335215e..f7dc9c9 100644
--- a/dlls/wininet/tests/ftp.c
+++ b/dlls/wininet/tests/ftp.c
@@ -66,6 +66,8 @@ static void test_connect(HINTERNET hInternet)
* anonymous : NULL
* NULL : IEUser@
* NULL : NULL
+ * "" : IEUser@
+ * "" : NULL
*/
SetLastError(0xdeadbeef);
@@ -85,6 +87,13 @@ static void test_connect(HINTERNET hInternet)
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+ SetLastError(0xdeadbeef);
+ hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "", "IEUser@",
+ INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
+ ok(!hFtp, "Expected InternetConnect to fail\n");
+ ok(GetLastError() == ERROR_INVALID_PARAMETER,
+ "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
+
/* Using a NULL username and password will be interpreted as anonymous ftp. The username will be 'anonymous' the password
* is created via some simple heuristics (see dlls/wininet/ftp.c).
* On Wine this registry key is not set by default so (NULL, NULL) will result in anonymous ftp with an (most likely) not
@@ -103,6 +112,20 @@ static void test_connect(HINTERNET hInternet)
ok ( hFtp != NULL, "InternetConnect failed : %d\n", GetLastError());
ok ( GetLastError() == ERROR_SUCCESS,
"ERROR_SUCCESS, got %d\n", GetLastError());
+
+ SetLastError(0xdeadbeef);
+ hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "", NULL,
+ INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
+ if (!hFtp)
+ {
+ ok(GetLastError() == ERROR_INTERNET_LOGIN_FAILURE,
+ "Expected ERROR_INTERNET_LOGIN_FAILURE, got %d\n", GetLastError());
+ }
+ else
+ {
+ ok(GetLastError() == ERROR_SUCCESS,
+ "Expected ERROR_SUCCESS, got %d\n", GetLastError());
+ }
}
static void test_createdir(HINTERNET hFtp, HINTERNET hConnect)
--
1.5.6.4
--------------040508000709060404070308--
More information about the wine-patches
mailing list