diff --git a/src/AspNetCore/Src/applicationinfo.cpp b/src/AspNetCore/Src/applicationinfo.cpp index ef6b943abb..36fa89a5a5 100644 --- a/src/AspNetCore/Src/applicationinfo.cpp +++ b/src/AspNetCore/Src/applicationinfo.cpp @@ -369,7 +369,8 @@ APPLICATION_INFO::FindNativeAssemblyFromHostfxr( INT intIndex = -1; INT intPrevIndex = 0; BOOL fFound = FALSE; - DWORD dwBufferSize = 1024 * 10; + DWORD dwBufferSize = 1024; + DWORD dwRequiredBufferSize = 0; DBG_ASSERT(struFileName != NULL); @@ -404,16 +405,17 @@ APPLICATION_INFO::FindNativeAssemblyFromHostfxr( m_pConfiguration->QueryHostFxrArgCount(), m_pConfiguration->QueryHostFxrArguments(), struNativeSearchPaths.QueryStr(), - dwBufferSize + dwBufferSize, + &dwRequiredBufferSize ); if (intHostFxrExitCode == 0) { break; } - else if (intHostFxrExitCode == API_BUFFER_TOO_SMALL) + else if (dwRequiredBufferSize >= dwBufferSize) { - dwBufferSize *= 2; // smaller buffer. increase the buffer and retry + dwBufferSize = dwRequiredBufferSize + 1; // for null terminator if (FAILED(hr = struNativeSearchPaths.Resize(dwBufferSize))) { goto Finished; diff --git a/src/CommonLib/hostfxr_utility.h b/src/CommonLib/hostfxr_utility.h index e73b26fa6e..1945574608 100644 --- a/src/CommonLib/hostfxr_utility.h +++ b/src/CommonLib/hostfxr_utility.h @@ -3,7 +3,7 @@ #pragma once -typedef INT(*hostfxr_get_native_search_directories_fn) (const int argc, const PCWSTR argv[], PCWSTR dest, size_t dest_size); +typedef INT(*hostfxr_get_native_search_directories_fn) (CONST INT argc, CONST PCWSTR* argv, PWSTR buffer, DWORD buffer_size, DWORD* required_buffer_size); typedef INT(*hostfxr_main_fn) (CONST DWORD argc, CONST PCWSTR argv[]); #define READ_BUFFER_SIZE 4096 diff --git a/src/RequestHandler/inprocess/inprocesshandler.cpp b/src/RequestHandler/inprocess/inprocesshandler.cpp index 92e41649cc..e4b769ca96 100644 --- a/src/RequestHandler/inprocess/inprocesshandler.cpp +++ b/src/RequestHandler/inprocess/inprocesshandler.cpp @@ -143,4 +143,4 @@ IN_PROCESS_HANDLER::SetManangedHttpContext( ) { m_pManagedHttpContext = pManagedHttpContext; -} \ No newline at end of file +}