diff --git a/src/dtf/SfxCA/SfxUtil.cpp b/src/dtf/SfxCA/SfxUtil.cpp index 1bf2c5b28..2e6b05558 100644 --- a/src/dtf/SfxCA/SfxUtil.cpp +++ b/src/dtf/SfxCA/SfxUtil.cpp @@ -93,7 +93,9 @@ bool DeleteDirectory(const wchar_t* szDir) StringCchCopy(szPath + cchDir + 1, cchPathBuf - (cchDir + 1), fd.cFileName); if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { - if (wcscmp(fd.cFileName, L".") != 0 && wcscmp(fd.cFileName, L"..") != 0) + if (wcscmp(fd.cFileName, L".") != 0 + && wcscmp(fd.cFileName, L"..") != 0 + && ((fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) == 0)) { DeleteDirectory(szPath); } diff --git a/src/ext/Util/ca/RemoveFoldersEx.cpp b/src/ext/Util/ca/RemoveFoldersEx.cpp index 10345de75..9523dda7d 100644 --- a/src/ext/Util/ca/RemoveFoldersEx.cpp +++ b/src/ext/Util/ca/RemoveFoldersEx.cpp @@ -38,6 +38,14 @@ static HRESULT RecursePath( } #endif + // Do NOT follow junctions. + DWORD dwAttributes = ::GetFileAttributesW(wzPath); + if (dwAttributes & FILE_ATTRIBUTE_REPARSE_POINT) + { + WcaLog(LOGMSG_STANDARD, "Path is a junction; skipping: %ls", wzPath); + ExitFunction(); + } + // First recurse down to all the child directories. hr = StrAllocFormatted(&sczSearch, L"%s*", wzPath); ExitOnFailure(hr, "Failed to allocate file search string in path: %S", wzPath); @@ -210,10 +218,10 @@ extern "C" UINT WINAPI WixRemoveFoldersEx( hr = PathExpand(&sczExpandedPath, sczPath, PATH_EXPAND_ENVIRONMENT); ExitOnFailure(hr, "Failed to expand path: %S for row: %S", sczPath, sczId); - + hr = PathBackslashTerminate(&sczExpandedPath); ExitOnFailure(hr, "Failed to backslash-terminate path: %S", sczExpandedPath); - + WcaLog(LOGMSG_STANDARD, "Recursing path: %S for row: %S.", sczExpandedPath, sczId); hr = RecursePath(sczExpandedPath, sczId, sczComponent, sczProperty, iMode, f64BitComponent, &dwCounter, &hTable, &hColumns); ExitOnFailure(hr, "Failed while navigating path: %S for row: %S", sczPath, sczId);