wininet: Improve FtpOpenFile()'s parameter checking and remove the corresponding todo_wines.

Francois Gouget fgouget at free.fr
Fri Feb 16 12:52:48 CST 2007


Also make test_getfile_no_open() succeed on Windows 98.
---

I have had some strange results with these tests. One of them was 
actually succeeding in a todo_wine for a good while.

 dlls/wininet/ftp.c       |   12 +++++++++++-
 dlls/wininet/tests/ftp.c |   12 +++---------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index 5b073cf..2bd29fd 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -1011,11 +1011,21 @@ HINTERNET WINAPI FtpOpenFileW(HINTERNET hFtpSession,
         debugstr_w(lpszFileName), fdwAccess, dwFlags, dwContext);
 
     lpwfs = (LPWININETFTPSESSIONW) WININET_GetObject( hFtpSession );
-    if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
+    if (NULL == lpwfs)
+    {
+        INTERNET_SetLastError(ERROR_INTERNET_NOT_INITIALIZED);
+        goto lend;
+    }
+    if (WH_HFTPSESSION != lpwfs->hdr.htype)
     {
         INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
         goto lend;
     }
+    if (dwFlags & ~(INTERNET_FLAGS_MASK|FTP_TRANSFER_TYPE_MASK))
+    {
+        INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
+        goto lend;
+    }
 
     if (lpwfs->download_in_progress != NULL) {
 	INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
diff --git a/dlls/wininet/tests/ftp.c b/dlls/wininet/tests/ftp.c
index 43be942..7fa9805 100644
--- a/dlls/wininet/tests/ftp.c
+++ b/dlls/wininet/tests/ftp.c
@@ -50,9 +50,9 @@ static void test_getfile_no_open(void)
     SetLastError(0xdeadbeef);
     bRet = FtpGetFileA(NULL, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
     ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
-    todo_wine
-    ok ( GetLastError() == ERROR_INTERNET_NOT_INITIALIZED,
-        "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+    ok ( GetLastError() == ERROR_INTERNET_NOT_INITIALIZED ||
+         GetLastError() == ERROR_INVALID_HANDLE,
+        "Expected ERROR_INTERNET_NOT_INITIALIZED or ERROR_INVALID_HANDLE (win98), got %d\n", GetLastError());
 }
 
 static void test_connect(void)
@@ -455,24 +455,18 @@ static void test_openfile(void)
     /* Illegal condition flags */
     SetLastError(0xdeadbeef);
     hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, 5, 0);
-    todo_wine
-    {
     ok ( !hOpenFile, "Expected FtpOpenFileA to fail\n");
     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
-    }
     InternetCloseHandle(hOpenFile); /* Just in case */
 
     /* All OK */
     SetLastError(0xdeadbeef);
     hOpenFile = FtpOpenFileA(hFtp, "welcome.msg", GENERIC_READ, FTP_TRANSFER_TYPE_ASCII, 0);
-    todo_wine
-    {
     ok ( hOpenFile != NULL, "Expected FtpOpenFileA to succeed\n");
     /* For some strange/unknown reason, win98 returns ERROR_FILE_NOT_FOUND */
     ok ( GetLastError() == ERROR_SUCCESS || GetLastError() == ERROR_FILE_NOT_FOUND,
         "Expected ERROR_SUCCESS or ERROR_FILE_NOT_FOUND (win98), got %d\n", GetLastError());
-    }
 
     if (hOpenFile)
     {
-- 
1.4.4.4




More information about the wine-patches mailing list