diff options
| author | Bob Arnson <bob@firegiant.com> | 2024-09-27 22:09:24 -0400 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2024-12-26 21:46:38 -0800 |
| commit | aa2678906191e0535fad5634467f074aae049c09 (patch) | |
| tree | d4b4d03a313d12dac0f4ee7f81b1945b1293691e /src/ext/UI/ca/DriveCheck.cpp | |
| parent | 3986a0b375d5b536f897d6284770baf711afaf86 (diff) | |
| download | wix-aa2678906191e0535fad5634467f074aae049c09.tar.gz wix-aa2678906191e0535fad5634467f074aae049c09.tar.bz2 wix-aa2678906191e0535fad5634467f074aae049c09.zip | |
Drop CA path validation in WixUI by default.
Add `WixUI/ExtendedPathValidation="yes"` to opt-in.
Removed the WIXUI_DONTVALIDATEPATH runtime opt-out.
Fixes https://github.com/wixtoolset/issues/issues/8718
Relies on https://github.com/wixtoolset/wix/pull/563
Diffstat (limited to 'src/ext/UI/ca/DriveCheck.cpp')
| -rw-r--r-- | src/ext/UI/ca/DriveCheck.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/ext/UI/ca/DriveCheck.cpp b/src/ext/UI/ca/DriveCheck.cpp index fafd73c2..75e6ffd1 100644 --- a/src/ext/UI/ca/DriveCheck.cpp +++ b/src/ext/UI/ca/DriveCheck.cpp | |||
| @@ -12,21 +12,21 @@ static HRESULT PathIsRemovable(__in LPCWSTR pTargetFolder, __inout BOOL* fPathRe | |||
| 12 | UINT __stdcall ValidatePath(MSIHANDLE hInstall) | 12 | UINT __stdcall ValidatePath(MSIHANDLE hInstall) |
| 13 | { | 13 | { |
| 14 | HRESULT hr = S_OK; | 14 | HRESULT hr = S_OK; |
| 15 | 15 | ||
| 16 | LPWSTR pwszWixUIDir = NULL; | 16 | LPWSTR pwszWixUIDir = NULL; |
| 17 | LPWSTR pwszInstallPath = NULL; | 17 | LPWSTR pwszInstallPath = NULL; |
| 18 | BOOL fInstallPathIsRemote = TRUE; | 18 | BOOL fInstallPathIsRemote = TRUE; |
| 19 | BOOL fInstallPathIsRemoveable = TRUE; | 19 | BOOL fInstallPathIsRemoveable = TRUE; |
| 20 | 20 | ||
| 21 | hr = WcaInitialize(hInstall, "ValidatePath"); | 21 | hr = WcaInitialize(hInstall, "ValidatePath"); |
| 22 | ExitOnFailure(hr, "failed to initialize"); | 22 | ExitOnFailure(hr, "failed to initialize"); |
| 23 | 23 | ||
| 24 | hr = WcaGetProperty(L"WIXUI_INSTALLDIR", &pwszWixUIDir); | 24 | hr = WcaGetProperty(L"WIXUI_INSTALLDIR", &pwszWixUIDir); |
| 25 | ExitOnFailure(hr, "failed to get WixUI Installation Directory"); | 25 | ExitOnFailure(hr, "failed to get WixUI Installation Directory"); |
| 26 | 26 | ||
| 27 | hr = WcaGetProperty(pwszWixUIDir, &pwszInstallPath); | 27 | hr = WcaGetProperty(pwszWixUIDir, &pwszInstallPath); |
| 28 | ExitOnFailure(hr, "failed to get Installation Directory"); | 28 | ExitOnFailure(hr, "failed to get Installation Directory"); |
| 29 | 29 | ||
| 30 | hr = PathIsRemote(pwszInstallPath, &fInstallPathIsRemote); | 30 | hr = PathIsRemote(pwszInstallPath, &fInstallPathIsRemote); |
| 31 | if (FAILED(hr)) | 31 | if (FAILED(hr)) |
| 32 | { | 32 | { |
| @@ -34,7 +34,7 @@ UINT __stdcall ValidatePath(MSIHANDLE hInstall) | |||
| 34 | //reset HR, as we need to continue and find out if is a UNC path | 34 | //reset HR, as we need to continue and find out if is a UNC path |
| 35 | hr = S_OK; | 35 | hr = S_OK; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | hr = PathIsRemovable(pwszInstallPath, &fInstallPathIsRemoveable); | 38 | hr = PathIsRemovable(pwszInstallPath, &fInstallPathIsRemoveable); |
| 39 | if (FAILED(hr)) | 39 | if (FAILED(hr)) |
| 40 | { | 40 | { |
| @@ -45,7 +45,7 @@ UINT __stdcall ValidatePath(MSIHANDLE hInstall) | |||
| 45 | 45 | ||
| 46 | // If the path does not point to a network drive, mapped drive, or removable drive, | 46 | // If the path does not point to a network drive, mapped drive, or removable drive, |
| 47 | // then set WIXUI_INSTALLDIR_VALID to "1" otherwise set it to 0 | 47 | // then set WIXUI_INSTALLDIR_VALID to "1" otherwise set it to 0 |
| 48 | BOOL fInstallPathIsUnc = PathIsUNCW(pwszInstallPath); | 48 | BOOL fInstallPathIsUnc = ::PathIsUNCW(pwszInstallPath); |
| 49 | if (!fInstallPathIsUnc && !fInstallPathIsRemote && !fInstallPathIsRemoveable) | 49 | if (!fInstallPathIsUnc && !fInstallPathIsRemote && !fInstallPathIsRemoveable) |
| 50 | { | 50 | { |
| 51 | // path is valid | 51 | // path is valid |
| @@ -61,7 +61,7 @@ UINT __stdcall ValidatePath(MSIHANDLE hInstall) | |||
| 61 | hr = WcaSetProperty(L"WIXUI_INSTALLDIR_VALID", L"0"); | 61 | hr = WcaSetProperty(L"WIXUI_INSTALLDIR_VALID", L"0"); |
| 62 | ExitOnFailure(hr, "failed to set WIXUI_INSTALLDIR_VALID"); | 62 | ExitOnFailure(hr, "failed to set WIXUI_INSTALLDIR_VALID"); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | LExit: | 65 | LExit: |
| 66 | ReleaseStr(pwszInstallPath); | 66 | ReleaseStr(pwszInstallPath); |
| 67 | ReleaseStr(pwszWixUIDir); | 67 | ReleaseStr(pwszWixUIDir); |
| @@ -79,22 +79,22 @@ static HRESULT PathIsRemote(__in LPCWSTR pTargetFolder, __inout BOOL* fPathRemot | |||
| 79 | LPWSTR pStrippedTargetFolder = NULL; | 79 | LPWSTR pStrippedTargetFolder = NULL; |
| 80 | 80 | ||
| 81 | hr = StrAllocString(&pStrippedTargetFolder, pTargetFolder, 0); | 81 | hr = StrAllocString(&pStrippedTargetFolder, pTargetFolder, 0); |
| 82 | 82 | ||
| 83 | // Terminate the path at the root | 83 | // Terminate the path at the root |
| 84 | if(!::PathStripToRootW(pStrippedTargetFolder)) | 84 | if (!::PathStripToRootW(pStrippedTargetFolder)) |
| 85 | { | 85 | { |
| 86 | hr = HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE); | 86 | hr = HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE); |
| 87 | ExitOnFailure(hr, "failed to parse target folder"); | 87 | ExitOnFailure(hr, "failed to parse target folder"); |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | UINT uResult = GetDriveTypeW(pStrippedTargetFolder); | 90 | UINT uResult = ::GetDriveTypeW(pStrippedTargetFolder); |
| 91 | 91 | ||
| 92 | *fPathRemote = (DRIVE_REMOTE == uResult) ; | 92 | *fPathRemote = (DRIVE_REMOTE == uResult); |
| 93 | 93 | ||
| 94 | LExit: | 94 | LExit: |
| 95 | ReleaseStr(pStrippedTargetFolder); | 95 | ReleaseStr(pStrippedTargetFolder); |
| 96 | 96 | ||
| 97 | return hr; | 97 | return hr; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | /******************************************************************** | 100 | /******************************************************************** |
| @@ -107,16 +107,16 @@ static HRESULT PathIsRemovable(__in LPCWSTR pTargetFolder, __inout BOOL* fPathRe | |||
| 107 | LPWSTR pStrippedTargetFolder = NULL; | 107 | LPWSTR pStrippedTargetFolder = NULL; |
| 108 | 108 | ||
| 109 | hr = StrAllocString(&pStrippedTargetFolder, pTargetFolder, 0); | 109 | hr = StrAllocString(&pStrippedTargetFolder, pTargetFolder, 0); |
| 110 | 110 | ||
| 111 | // Terminate the path at the root | 111 | // Terminate the path at the root |
| 112 | if(!::PathStripToRootW(pStrippedTargetFolder)) | 112 | if (!::PathStripToRootW(pStrippedTargetFolder)) |
| 113 | { | 113 | { |
| 114 | hr = HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE); | 114 | hr = HRESULT_FROM_WIN32(ERROR_INVALID_DRIVE); |
| 115 | ExitOnFailure(hr, "failed to parse target folder"); | 115 | ExitOnFailure(hr, "failed to parse target folder"); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | UINT uResult = GetDriveTypeW(pStrippedTargetFolder); | 118 | UINT uResult = ::GetDriveTypeW(pStrippedTargetFolder); |
| 119 | 119 | ||
| 120 | *fPathRemovable = ((DRIVE_CDROM == uResult) || (DRIVE_REMOVABLE == uResult) || (DRIVE_RAMDISK == uResult) || (DRIVE_UNKNOWN == uResult)); | 120 | *fPathRemovable = ((DRIVE_CDROM == uResult) || (DRIVE_REMOVABLE == uResult) || (DRIVE_RAMDISK == uResult) || (DRIVE_UNKNOWN == uResult)); |
| 121 | 121 | ||
| 122 | LExit: | 122 | LExit: |
