From 638532e58ab4c06c35f17421d36ae02ef02ffaf2 Mon Sep 17 00:00:00 2001 From: Bevan Weiss Date: Fri, 2 Aug 2024 22:19:02 +1000 Subject: Fix up small inaccuracy in logged error message. When ::GetFileAttributesW returns 0xFFFFFFFF it means 'Invalid File/Folder' So we should return a matching error message. To avoid confusing invalid paths with junctions (in error message) Unfortunately the constant for this is not defined. So just define it here as though it would be. Signed-off-by: Bevan Weiss --- src/ext/Util/ca/RemoveFoldersEx.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/ext') diff --git a/src/ext/Util/ca/RemoveFoldersEx.cpp b/src/ext/Util/ca/RemoveFoldersEx.cpp index f162e929..5e813ca2 100644 --- a/src/ext/Util/ca/RemoveFoldersEx.cpp +++ b/src/ext/Util/ca/RemoveFoldersEx.cpp @@ -2,6 +2,12 @@ #include "precomp.h" +// Whilst ::GetFileAttributesW might return FILE_ATTRIBUTE_INVALID for an invalid path, it's not a header defined variable. +// so define it here, but guard it to avoid redefining it if Microsoft change their mind +#ifndef FILE_ATTRIBUTE_INVALID +#define FILE_ATTRIBUTE_INVALID ((DWORD)-1) +#endif + LPCWSTR vcsRemoveFolderExQuery = L"SELECT `RemoveFolderEx`, `Component_`, `Property`, `InstallMode`, `Wix4RemoveFolderEx`.`Condition`, `Component`.`Attributes` " L"FROM `Wix4RemoveFolderEx`,`Component` " @@ -38,8 +44,14 @@ static HRESULT RecursePath( } #endif - // Do NOT follow junctions. DWORD dwAttributes = ::GetFileAttributesW(wzPath); + if (FILE_ATTRIBUTE_INVALID == dwAttributes) + { + WcaLog(LOGMSG_STANDARD, "Path is invalid: %ls", wzPath); + ExitFunction(); + } + + // Do NOT follow junctions. if (dwAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { WcaLog(LOGMSG_STANDARD, "Path is a junction; skipping: %ls", wzPath); -- cgit v1.2.3-55-g6feb