Commit 35759184 authored by Phil Lodwick's avatar Phil Lodwick Committed by Alexandre Julliard

wininet: ftp: Fix crash if input buffer is larger than MAX_PATH.

parent 5ea41cc5
......@@ -746,16 +746,29 @@ lend:
BOOL WINAPI FtpGetCurrentDirectoryA(HINTERNET hFtpSession, LPSTR lpszCurrentDirectory,
LPDWORD lpdwCurrentDirectory)
{
WCHAR dir[MAX_PATH];
WCHAR *dir = NULL;
DWORD len;
BOOL ret;
if(lpdwCurrentDirectory) len = *lpdwCurrentDirectory;
if(lpdwCurrentDirectory) {
len = *lpdwCurrentDirectory;
if(lpszCurrentDirectory)
{
dir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (NULL == dir)
{
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
return FALSE;
}
}
}
ret = FtpGetCurrentDirectoryW(hFtpSession, lpszCurrentDirectory?dir:NULL, lpdwCurrentDirectory?&len:NULL);
if(lpdwCurrentDirectory) {
*lpdwCurrentDirectory = len;
if(lpszCurrentDirectory)
if(lpszCurrentDirectory) {
WideCharToMultiByte(CP_ACP, 0, dir, len, lpszCurrentDirectory, *lpdwCurrentDirectory, NULL, NULL);
HeapFree(GetProcessHeap(), 0, dir);
}
}
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment