[2/2] wininet: Fix error handling in FtpSetCurrentDirectoryW [try 2]

Zac Brown zac at zacbrown.org
Mon Dec 10 14:15:25 CST 2007


Hi,

Changelog:
* Fix error handling in FtpSetCurrentDirectoryW



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

diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index ed3fbea..1161cb5 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -5,7 +5,8 @@
  * Copyright 2004 Mike McCormack for CodeWeavers
  * Copyright 2004 Kevin Koltzau
  * Copyright 2007 Hans Leidekker
- *
+ * Copyright 2007 Zac Brown
+ *
  * Ulrich Czekalla
  * Noureddine Jemmali
  *
@@ -386,19 +387,25 @@ BOOL WINAPI FtpSetCurrentDirectoryW(HINTERNET hConnect, LPCWSTR lpszDirectory)
     LPWININETAPPINFOW hIC = NULL;
     BOOL r = FALSE;

-    if (!lpszDirectory)
+    lpwfs = (LPWININETFTPSESSIONW) WININET_GetObject( hConnect );
+    if (NULL == lpwfs)
     {
-        INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
+        INTERNET_SetLastError(ERROR_INVALID_HANDLE);
         goto lend;
     }
-
-    lpwfs = (LPWININETFTPSESSIONW) WININET_GetObject( hConnect );
-    if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
+
+    if (WH_HFTPSESSION != lpwfs->hdr.htype)
     {
         INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
         goto lend;
     }

+    if (!lpszDirectory)
+    {
+        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 6542e67..db23740 100644
--- a/dlls/wininet/tests/ftp.c
+++ b/dlls/wininet/tests/ftp.c
@@ -3,6 +3,7 @@
  *
  * Copyright 2007 Paul Vriens
  * Copyright 2007 Hans Leidekker
+ * Copyright 2007 Zac Brown
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,9 +27,7 @@
  *     Add W-function tests.
  *     Add missing function tests:
  *         FtpFindFirstFile
- *         FtpGetCurrentDirectory
  *         FtpGetFileSize
- *         FtpSetCurrentDirectory
  */

 #include <stdarg.h>
@@ -780,14 +779,12 @@ test_set_current_dir(HINTERNET hFtp, HINTERNET hConnect)
     SetLastError(0xdeadbeef);
     bRet = FtpSetCurrentDirectoryA(NULL, NULL);
     ok ( bRet == FALSE, "Expected FtpSetCurrentDirectoryA to fail\n");
-todo_wine
     ok ( GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got: %d\n", GetLastError());

     /* test with NULL handle */
     SetLastError(0xdeadbeef);
     bRet = FtpSetCurrentDirectory(NULL, testDirectory);
     ok ( bRet == FALSE, "Expected FtpSetCurrentDirectoryA to fail\n");
-todo_wine
     ok ( GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got: %d\n", GetLastError());

     /* test with bad handle */
-- 
1.5.2.5




More information about the wine-patches mailing list