[1/2] wininet: Fix remaining errors in FtpGetCurrentDirectory relevant functions

Zac Brown zac at zacbrown.org
Mon Dec 3 21:34:05 CST 2007


Hi,

Changelog:
* Fix the remaining errors in error handling for the group of functions related to FtpGetCurrentDirectory in wininet/ftp.c

Notes:
* This brings these functions up to par with the tests and has a corresponding patch to wininet/tests/ftp.c




---
 dlls/wininet/ftp.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index ce60fa0..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
@@ -830,6 +831,9 @@ BOOL WINAPI FtpGetCurrentDirectoryA(HINTERNET hFtpSession, LPSTR lpszCurrentDire
     WCHAR *dir = NULL;
     DWORD len;
     BOOL ret;
+
+    if(lpszCurrentDirectory && lpdwCurrentDirectory)
+        ZeroMemory(lpszCurrentDirectory, *lpdwCurrentDirectory * sizeof(CHAR));

     if(lpdwCurrentDirectory) {
         len = *lpdwCurrentDirectory;
@@ -994,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);
-- 
1.5.2.5



More information about the wine-patches mailing list