Skip to content

Commit

Permalink
Do not follow junctions when recursively deleting directories
Browse files Browse the repository at this point in the history
This will prevent elevated processes from accidentally following a junction
from a user-writable directory to a per-machine directory and erroneously
deleting the per-machine contents.
  • Loading branch information
robmen committed Mar 6, 2024
1 parent c4ab058 commit 4f94fc4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libs/dutil/WixToolset.DUtil/dirutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*******************************************************************/
extern "C" BOOL DAPI DirExists(
__in_z LPCWSTR wzPath,
__in_z LPCWSTR wzPath,
__out_opt DWORD *pdwAttributes
)
{
Expand Down Expand Up @@ -73,7 +73,7 @@ extern "C" HRESULT DAPI DirCreateTempPath(
*******************************************************************/
extern "C" HRESULT DAPI DirEnsureExists(
__in_z LPCWSTR wzPath,
__in_z LPCWSTR wzPath,
__in_opt LPSECURITY_ATTRIBUTES psa
)
{
Expand Down Expand Up @@ -203,8 +203,8 @@ extern "C" HRESULT DAPI DirEnsureDeleteEx(
}
}

// If we're deleting files and/or child directories loop through the contents of the directory.
if (fDeleteFiles || fRecurse)
// If we're deleting files and/or child directories loop through the contents of the directory, but skip junctions.
if ((fDeleteFiles || fRecurse) && (0 == (dwAttrib & FILE_ATTRIBUTE_REPARSE_POINT)))
{
if (fScheduleDelete)
{
Expand Down

0 comments on commit 4f94fc4

Please sign in to comment.