Skip to content

Commit dca5ec4

Browse files
committed
Don't recursive copy
1 parent 254ab40 commit dca5ec4

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/Servers/IIS/AspNetCoreModuleV2/AspNetCore/applicationinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ APPLICATION_INFO::HandleShadowCopy(const ShimOptions& options, IHttpContext& pHt
304304
}
305305

306306
shadowCopyPath = shadowCopyPath / directoryNameStr;
307-
HRESULT hr = Environment::CopyToDirectory(physicalPath, shadowCopyPath, options.QueryCleanShadowCopyDirectory(), shadowCopyBaseDirectory.path().parent_path());
307+
HRESULT hr = Environment::CopyToDirectory(physicalPath, shadowCopyPath, options.QueryCleanShadowCopyDirectory(), std::filesystem::canonical(shadowCopyBaseDirectory.path()));
308308
if (hr != S_OK)
309309
{
310310
return std::wstring();

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/Environment.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ void Environment::CopyToDirectoryInner(const std::filesystem::path& source, cons
192192
}
193193
else if (path.is_directory())
194194
{
195-
auto sourceInnerDirectory = std::filesystem::directory_entry(path);
196-
if (sourceInnerDirectory.path() != directoryToIgnore)
195+
auto sourceInnerDirectory = path.path();
196+
197+
// Make sure we aren't navigating into shadow copy directory.
198+
if (sourceInnerDirectory.wstring().rfind(directoryToIgnore, 0) != 0)
197199
{
198200
CopyToDirectoryInner(path.path(), destination / path.path().filename(), directoryToIgnore);
199201
}

src/Servers/IIS/AspNetCoreModuleV2/RequestHandlerLib/filewatcher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ DWORD WINAPI FILE_WATCHER::CopyAndShutdown(FILE_WATCHER* watcher)
366366
// Copy contents before shutdown
367367
try
368368
{
369-
Environment::CopyToDirectory(watcher->_strDirectoryName.QueryStr(), destination, false, parentDirectory);
369+
Environment::CopyToDirectory(watcher->_strDirectoryName.QueryStr(), destination, false, std::filesystem::canonical(parentDirectory));
370370
}
371371
catch (...)
372372
{

0 commit comments

Comments
 (0)