diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-06-03 17:49:33 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-06-07 19:44:36 -0500 |
commit | 266b097c0b0a13dd4934f55f61cad62ffcbb953d (patch) | |
tree | 21400e8e1f7a6a5ebbc1abaacb40c472fc0b9fbc /src/libs/dutil/WixToolset.DUtil/pathutil.cpp | |
parent | 584213c5ffeca09b3fe24bd5e92f73fd057ac642 (diff) | |
download | wix-266b097c0b0a13dd4934f55f61cad62ffcbb953d.tar.gz wix-266b097c0b0a13dd4934f55f61cad62ffcbb953d.tar.bz2 wix-266b097c0b0a13dd4934f55f61cad62ffcbb953d.zip |
REG_EXPAND_SZ values are not necessarily a path.
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/pathutil.cpp')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/pathutil.cpp | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/pathutil.cpp b/src/libs/dutil/WixToolset.DUtil/pathutil.cpp index dc33e656..becfc67e 100644 --- a/src/libs/dutil/WixToolset.DUtil/pathutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/pathutil.cpp | |||
@@ -181,10 +181,8 @@ DAPI_(HRESULT) PathExpand( | |||
181 | Assert(wzRelativePath); | 181 | Assert(wzRelativePath); |
182 | 182 | ||
183 | HRESULT hr = S_OK; | 183 | HRESULT hr = S_OK; |
184 | DWORD cch = 0; | ||
185 | LPWSTR sczExpandedPath = NULL; | 184 | LPWSTR sczExpandedPath = NULL; |
186 | SIZE_T cchWritten = 0; | 185 | SIZE_T cchWritten = 0; |
187 | DWORD cchExpandedPath = 0; | ||
188 | LPWSTR sczFullPath = NULL; | 186 | LPWSTR sczFullPath = NULL; |
189 | DWORD dwPrefixFlags = 0; | 187 | DWORD dwPrefixFlags = 0; |
190 | 188 | ||
@@ -193,35 +191,8 @@ DAPI_(HRESULT) PathExpand( | |||
193 | // | 191 | // |
194 | if (dwResolveFlags & PATH_EXPAND_ENVIRONMENT) | 192 | if (dwResolveFlags & PATH_EXPAND_ENVIRONMENT) |
195 | { | 193 | { |
196 | cchExpandedPath = PATH_GOOD_ENOUGH; | 194 | hr = EnvExpandEnvironmentStrings(wzRelativePath, &sczExpandedPath, &cchWritten); |
197 | 195 | PathExitOnFailure(hr, "Failed to expand environment variables in string: %ls", wzRelativePath); | |
198 | hr = StrAlloc(&sczExpandedPath, cchExpandedPath); | ||
199 | PathExitOnFailure(hr, "Failed to allocate space for expanded path."); | ||
200 | |||
201 | cch = ::ExpandEnvironmentStringsW(wzRelativePath, sczExpandedPath, cchExpandedPath); | ||
202 | if (0 == cch) | ||
203 | { | ||
204 | PathExitWithLastError(hr, "Failed to expand environment variables in string: %ls", wzRelativePath); | ||
205 | } | ||
206 | else if (cchExpandedPath < cch) | ||
207 | { | ||
208 | cchExpandedPath = cch; | ||
209 | hr = StrAlloc(&sczExpandedPath, cchExpandedPath); | ||
210 | PathExitOnFailure(hr, "Failed to re-allocate more space for expanded path."); | ||
211 | |||
212 | cch = ::ExpandEnvironmentStringsW(wzRelativePath, sczExpandedPath, cchExpandedPath); | ||
213 | if (0 == cch) | ||
214 | { | ||
215 | PathExitWithLastError(hr, "Failed to expand environment variables in string: %ls", wzRelativePath); | ||
216 | } | ||
217 | else if (cchExpandedPath < cch) | ||
218 | { | ||
219 | hr = HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); | ||
220 | PathExitOnRootFailure(hr, "Failed to allocate buffer for expanded path."); | ||
221 | } | ||
222 | } | ||
223 | |||
224 | cchWritten = cch; | ||
225 | } | 196 | } |
226 | 197 | ||
227 | // | 198 | // |