[1/2] wininet: Fix FtpGetCurrentDirectoryW to set proper errors (RESEND)

Zac Brown zac at zacbrown.org
Mon Dec 3 21:55:39 CST 2007


Hi,

Changelog:
* Add proper code to set correct errors in wininet/ftp.c:FtpGetCurrentDirectoryW



---
 dlls/wininet/ftp.c       |   11 ++++++++++-
 dlls/wininet/tests/ftp.c |    3 +--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index 203997b..55e24a1 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -5,6 +5,7 @@
  * Copyright 2004 Mike McCormack for CodeWeavers
  * Copyright 2004 Kevin Koltzau
  * Copyright 2007 Hans Leidekker
+ * Copyright 2007 Zac Brown
  *
  * Ulrich Czekalla
  * Noureddine Jemmali
@@ -997,8 +998,16 @@ BOOL WINAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszC
             len = lastpos - firstpos - 1;
             lstrcpynW(lpszCurrentDirectory, &lpszResponseBuffer[firstpos+1], *lpdwCurrentDirectory);
             HeapFree(GetProcessHeap(), 0, lpszResponseBuffer);
+            if (len >= *lpdwCurrentDirectory)
+            {
+                INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
+                bSuccess = FALSE;
+            }
+            else
+            {
+                bSuccess = TRUE;
+            }
             *lpdwCurrentDirectory = len;
-            bSuccess = TRUE;
         }
         else
             FTP_SetResponseError(nResCode);
diff --git a/dlls/wininet/tests/ftp.c b/dlls/wininet/tests/ftp.c
index 0598577..2276be2 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
@@ -756,10 +757,8 @@ static void test_get_current_dir(HINTERNET hFtp, HINTERNET hConnect)
     dwCurrentDirectoryLen = 4;
     lpszCurrentDirectory[4] = 'a'; /* set position 4 of the array to something else to make sure a leftover \0 isn't fooling the test */
     bRet = FtpGetCurrentDirectoryA( hFtp, lpszCurrentDirectory, &dwCurrentDirectoryLen );
-todo_wine
     ok ( bRet == FALSE, "Expected FtpGetCurrentDirectoryA to fail\n");
     ok ( lstrcmp(lpszCurrentDirectory, "/pub") != 0, "Expected returned value \"%s\" to not match \"%s\" \n", (char*)lpszCurrentDirectory, "/pub");
-todo_wine
     ok ( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Expected ERROR_INSUFFICIENT_BUFFER, got: %d\n", GetLastError());

     /* test for the current directory with a size large enough to store
-- 
1.5.2.5



More information about the wine-patches mailing list