[wininet/ftp.c] #3 Fix some returned error codes

Paul Vriens paul.vriens.wine at gmail.com
Sat Feb 10 10:33:17 CST 2007


Hi,

Fixes for FtpRenameFile[A|W].

The fixes should also please Coverity CID-179 and CID-180.

Changelog
       Fix some returned error codes

Cheers,

Paul.

-------------- next part --------------
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index 6a0275c..56fade1 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -1667,12 +1667,24 @@ BOOL WINAPI FtpRenameFileW(HINTERNET hFtpSession, LPCWSTR lpszSrc, LPCWSTR lpszD
     BOOL r = FALSE;
 
     lpwfs = (LPWININETFTPSESSIONW) WININET_GetObject( hFtpSession );
-    if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
+    if (!lpwfs)
+    {
+        INTERNET_SetLastError(ERROR_INVALID_HANDLE);
+        return FALSE;
+    }
+
+    if (WH_HFTPSESSION != lpwfs->hdr.htype)
     {
         INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
         goto lend;
     }
 
+    if (!lpszSrc || !lpszDest)
+    {
+        INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
+        goto lend;
+    }
+
     hIC = lpwfs->lpAppInfo;
     if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
     {
@@ -1693,8 +1705,7 @@ BOOL WINAPI FtpRenameFileW(HINTERNET hFtpSession, LPCWSTR lpszSrc, LPCWSTR lpszD
     }
 
 lend:
-    if( lpwfs )
-        WININET_Release( &lpwfs->hdr );
+    WININET_Release( &lpwfs->hdr );
 
     return r;
 }
diff --git a/dlls/wininet/tests/ftp.c b/dlls/wininet/tests/ftp.c
index f389816..0e566b1 100644
--- a/dlls/wininet/tests/ftp.c
+++ b/dlls/wininet/tests/ftp.c
@@ -666,7 +666,6 @@ static void test_renamefile(void)
     SetLastError(0xdeadbeef);
     bRet = FtpRenameFileA(NULL , "should_be_non_existing_deadbeef", "new");
     ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
-    todo_wine
     ok ( GetLastError() == ERROR_INVALID_HANDLE,
         "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
 
@@ -685,7 +684,6 @@ static void test_renamefile(void)
     SetLastError(0xdeadbeef);
     bRet = FtpRenameFileA(hFtp , NULL, "new");
     ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
-    todo_wine
     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
 
@@ -693,7 +691,6 @@ static void test_renamefile(void)
     SetLastError(0xdeadbeef);
     bRet = FtpRenameFileA(hFtp , "should_be_non_existing_deadbeef", NULL);
     ok ( bRet == FALSE, "Expected FtpRenameFileA to fail\n");
-    todo_wine
     ok ( GetLastError() == ERROR_INVALID_PARAMETER,
         "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
 
-- 
1.4.4.4




More information about the wine-patches mailing list