From 135aa12529ae91f0699bca277216a65dd973e149 Mon Sep 17 00:00:00 2001 From: jhkimnew Date: Fri, 10 Feb 2017 14:35:51 -0800 Subject: [PATCH] Remove MAX_PATH buffersize to support long file path (#69) This is already reviewed by Pan. --- src/AspNetCore/Src/path.cxx | 2 +- src/AspNetCore/Src/serverprocess.cxx | 33 ++++++++++++++++++---------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/AspNetCore/Src/path.cxx b/src/AspNetCore/Src/path.cxx index 0c6bb0f..a4ef464 100644 --- a/src/AspNetCore/Src/path.cxx +++ b/src/AspNetCore/Src/path.cxx @@ -348,7 +348,7 @@ PATH::IsPathUnc( ) { HRESULT hr = S_OK; - STACK_STRU( strTempPath, MAX_PATH ); + STRU strTempPath; if ( pszPath == NULL || pfIsUnc == NULL ) { diff --git a/src/AspNetCore/Src/serverprocess.cxx b/src/AspNetCore/Src/serverprocess.cxx index 20faa4d..c633625 100644 --- a/src/AspNetCore/Src/serverprocess.cxx +++ b/src/AspNetCore/Src/serverprocess.cxx @@ -118,6 +118,7 @@ SERVER_PROCESS::StartProcess( LPCWSTR pszRootApplicationPath = NULL; BOOL fDebuggerAttachedToChildProcess = FALSE; STRU strFullProcessPath; + STRU struRelativePath; STRU struApplicationId; RPC_STATUS rpcStatus; UUID logUuid; @@ -131,9 +132,10 @@ SERVER_PROCESS::StartProcess( // DWORD dwActualProcessId = 0; WCHAR* pszPath = NULL; - WCHAR pszFullPath[_MAX_PATH]; + WCHAR* pszFullPath = NULL; LPCWSTR apsz[1]; PCWSTR pszAppPath = NULL; + DWORD dwBufferSize = 0; GetStartupInfoW(&startupInfo); @@ -299,21 +301,24 @@ SERVER_PROCESS::StartProcess( if ((wcsstr(pszPath, L":") == NULL) && (wcsstr(pszPath, L"%") == NULL)) { // let's check whether it is a relative path - WCHAR pszRelativePath[_MAX_PATH]; - - if (swprintf_s(pszRelativePath, - _MAX_PATH, - L"%s\\%s", - pszRootApplicationPath, - pszPath) == -1) + if (FAILED(hr = struRelativePath.Copy(pszRootApplicationPath)) || + FAILED(hr = struRelativePath.Append(L"\\")) || + FAILED(hr = struRelativePath.Append(pszPath))) { - hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + goto Finished; + } + + dwBufferSize = struRelativePath.QueryCCH() + 1; + pszFullPath = new WCHAR[dwBufferSize]; + if (pszFullPath == NULL) + { + hr = E_OUTOFMEMORY; goto Finished; } if (_wfullpath(pszFullPath, - pszRelativePath, - _MAX_PATH) == NULL) + struRelativePath.QueryStr(), + dwBufferSize) == NULL) { hr = HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER); goto Finished; @@ -828,6 +833,12 @@ Finished: pszCommandLine = NULL; } + if (pszFullPath != NULL) + { + delete[] pszFullPath; + pszFullPath = NULL; + } + if (FAILED(hr) || m_fReady == FALSE) { if (m_hStdoutHandle != NULL)