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

Paul Vriens paul.vriens.wine at gmail.com
Thu Feb 8 10:27:57 CST 2007


Hi,

This fixes 2 returned error codes. There's one remaining todo_wine with respect
to ERROR_INTERNET_EXTENDED_ERROR but that's not on the short TODO-list.

I've opted for only doing the checks in FtpCreateDirectoryW as some of the
checks have to be in order. (This means that we could check twice for the
existence of lpszDirectory).

I've also removed the check for lpwfs as we already bail out on NULL.

This should also cater for Coverity CID-171.

Changelog
      Fix some returned error codes

Cheers,

Paul.



-------------- next part --------------
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index 4e99dae..1d9224b 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -507,12 +507,24 @@ BOOL WINAPI FtpCreateDirectoryW(HINTERNET hConnect, LPCWSTR lpszDirectory)
     BOOL r = FALSE;
 
     lpwfs = (LPWININETFTPSESSIONW) WININET_GetObject( hConnect );
-    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 (!lpszDirectory)
+    {
+        INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
+        goto lend;
+    }
+
     hIC = lpwfs->lpAppInfo;
     if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
     {
@@ -531,8 +543,7 @@ BOOL WINAPI FtpCreateDirectoryW(HINTERNET hConnect, LPCWSTR lpszDirectory)
         r = FTP_FtpCreateDirectoryW(lpwfs, lpszDirectory);
     }
 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 3a5fa70..d5a4a6f 100644
--- a/dlls/wininet/tests/ftp.c
+++ b/dlls/wininet/tests/ftp.c
@@ -106,7 +106,6 @@ static void test_createdir(void)
     SetLastError(0xdeadbeef);
     bRet = FtpCreateDirectoryA(NULL, "new_directory_deadbeef");
     ok ( bRet == FALSE, "Expected FtpCreateDirectoryA to fail\n");
-    todo_wine
     ok ( GetLastError() == ERROR_INVALID_HANDLE,
         "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
 
@@ -125,7 +124,6 @@ static void test_createdir(void)
     SetLastError(0xdeadbeef);
     bRet = FtpCreateDirectoryA(hFtp, NULL);
     ok ( bRet == FALSE, "Expected FtpCreateDirectoryA 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