Make sure base paths are fully qualified in Burn.
Sean Hall committed
Jun 3, 2022 at 17:50 UTC
68ec803fc7f48bb0e0463dc45f6ce40e1f07dbf5
14 files changed
+87
-40
src/burn/engine/apply.cpp
+1
-1
@@ -1371,7 +1371,7 @@ static HRESULT LayoutBundle(
1371
ExitOnFailure(hr, "Failed to get path to bundle to layout.");
1372
}
1373
1374
- hr = PathConcatRelativeToBase(pContext->wzLayoutDirectory, wzExecutableName, &sczDestinationPath);
1374
+ hr = PathConcatRelativeToFullyQualifiedBase(pContext->wzLayoutDirectory, wzExecutableName, &sczDestinationPath);
1375
ExitOnFailure(hr, "Failed to concat layout path for bundle.");
1376
1377
// If the destination path is the currently running bundle, bail.
src/burn/engine/bundlepackageengine.cpp
+1
-1
@@ -780,7 +780,7 @@ static HRESULT ExecuteBundle(
780
hr = CacheGetCompletedPath(pCache, pPackage->fPerMachine, pPackage->sczCacheId, &sczCachedDirectory);
781
ExitOnFailure(hr, "Failed to get cached path for package: %ls", pPackage->sczId);
782
783
- hr = PathConcatRelativeToBase(sczCachedDirectory, pPackagePayload->sczFilePath, &sczExecutablePath);
783
+ hr = PathConcatRelativeToFullyQualifiedBase(sczCachedDirectory, pPackagePayload->sczFilePath, &sczExecutablePath);
784
ExitOnFailure(hr, "Failed to build executable path.");
785
}
786
src/burn/engine/cache.cpp
+31
-25
@@ -188,13 +188,18 @@ extern "C" HRESULT CacheInitialize(
188
hr = PolcReadString(POLICY_BURN_REGISTRY_PATH, L"PackageCache", NULL, &pCache->sczCurrentMachinePackageCache);
189
ExitOnFailure(hr, "Failed to read PackageCache policy directory.");
190
191
- if (pCache->sczCurrentMachinePackageCache)
191
+ if (pCache->sczCurrentMachinePackageCache && PathIsFullyQualified(pCache->sczCurrentMachinePackageCache))
192
{
193
hr = PathBackslashTerminate(&pCache->sczCurrentMachinePackageCache);
194
ExitOnFailure(hr, "Failed to backslash terminate redirected per-machine package cache directory name.");
195
}
196
else
197
{
198
+ if (pCache->sczCurrentMachinePackageCache)
199
+ {
200
+ LogErrorId(E_INVALIDARG, MSG_INVALID_POLICY_MACHINE_PACKAGE_CACHE, pCache->sczCurrentMachinePackageCache, NULL, NULL);
201
+ }
202
+
203
hr = StrAllocString(&pCache->sczCurrentMachinePackageCache, pCache->sczDefaultMachinePackageCache, 0);
204
ExitOnFailure(hr, "Failed to copy default package cache directory to current package cache directory.");
205
}
@@ -251,7 +256,7 @@ extern "C" HRESULT CacheInitializeSources(
256
hr = CacheGetCompletedPath(pCache, pRegistration->fPerMachine, pRegistration->sczId, &sczCompletedFolder);
257
ExitOnFailure(hr, "Failed to get completed path for bundle.");
258
254
- hr = PathConcatRelativeToBase(sczCompletedFolder, pRegistration->sczExecutableName, &sczCompletedPath);
259
+ hr = PathConcatRelativeToFullyQualifiedBase(sczCompletedFolder, pRegistration->sczExecutableName, &sczCompletedPath);
260
ExitOnFailure(hr, "Failed to combine working path with engine file name.");
261
262
hr = PathCompareCanonicalized(sczCurrentPath, sczCompletedPath, &fPathEqual);
@@ -342,15 +347,16 @@ extern "C" HRESULT CacheEnsureBaseWorkingFolder(
347
{
348
for (DWORD i = 0; i < pCache->cPotentialBaseWorkingFolders; ++i)
349
{
345
- hr = PathConcatRelativeToBase(pCache->rgsczPotentialBaseWorkingFolders[i], pCache->wzGuid, &sczPotential);
346
- ExitOnFailure(hr, "Failed to append random guid on to potential path for working folder.");
347
-
348
- hr = DirEnsureExists(sczPotential, NULL);
350
+ hr = PathConcatRelativeToFullyQualifiedBase(pCache->rgsczPotentialBaseWorkingFolders[i], pCache->wzGuid, &sczPotential);
351
if (SUCCEEDED(hr))
352
{
351
- pCache->sczBaseWorkingFolder = sczPotential;
352
- sczPotential = NULL;
353
- break;
353
+ hr = DirEnsureExists(sczPotential, NULL);
354
+ if (SUCCEEDED(hr))
355
+ {
356
+ pCache->sczBaseWorkingFolder = sczPotential;
357
+ sczPotential = NULL;
358
+ break;
359
+ }
360
}
361
362
LogErrorId(hr, MSG_INVALID_BASE_WORKING_FOLDER, sczPotential, NULL, NULL);
@@ -414,7 +420,7 @@ extern "C" HRESULT CacheCalculateBundleLayoutWorkingPath(
420
421
HRESULT hr = S_OK;
422
417
- hr = PathConcatRelativeToBase(pCache->sczAcquisitionFolder, wzBundleId, psczWorkingPath);
423
+ hr = PathConcatRelativeToFullyQualifiedBase(pCache->sczAcquisitionFolder, wzBundleId, psczWorkingPath);
424
ExitOnFailure(hr, "Failed to append bundle id for bundle layout working path.");
425
426
LExit:
@@ -431,7 +437,7 @@ extern "C" HRESULT CacheCalculatePayloadWorkingPath(
437
438
HRESULT hr = S_OK;
439
434
- hr = PathConcatRelativeToBase(pCache->sczAcquisitionFolder, pPayload->sczKey, psczWorkingPath);
440
+ hr = PathConcatRelativeToFullyQualifiedBase(pCache->sczAcquisitionFolder, pPayload->sczKey, psczWorkingPath);
441
ExitOnFailure(hr, "Failed to append Id as payload unverified path.");
442
443
LExit:
@@ -448,7 +454,7 @@ extern "C" HRESULT CacheCalculateContainerWorkingPath(
454
455
HRESULT hr = S_OK;
456
451
- hr = PathConcatRelativeToBase(pCache->sczAcquisitionFolder, pContainer->sczHash, psczWorkingPath);
457
+ hr = PathConcatRelativeToFullyQualifiedBase(pCache->sczAcquisitionFolder, pContainer->sczHash, psczWorkingPath);
458
ExitOnFailure(hr, "Failed to append hash as container unverified path.");
459
460
LExit:
@@ -503,7 +509,7 @@ extern "C" HRESULT CacheGetCompletedPath(
509
// GetRootPath returns S_FALSE if the package cache is redirected elsewhere.
510
fRedirected = S_FALSE == hr;
511
506
- hr = PathConcatRelativeToBase(sczRootPath, wzCacheId, &sczCurrentCompletedPath);
512
+ hr = PathConcatRelativeToFullyQualifiedBase(sczRootPath, wzCacheId, &sczCurrentCompletedPath);
513
ExitOnFailure(hr, "Failed to construct cache path.");
514
515
hr = PathBackslashTerminate(&sczCurrentCompletedPath);
@@ -516,7 +522,7 @@ extern "C" HRESULT CacheGetCompletedPath(
522
hr = GetRootPath(pCache, fPerMachine, FALSE, &sczRootPath);
523
ExitOnFailure(hr, "Failed to get old %hs package cache root directory.", fPerMachine ? "per-machine" : "per-user");
524
519
- hr = PathConcatRelativeToBase(sczRootPath, wzCacheId, &sczDefaultCompletedPath);
525
+ hr = PathConcatRelativeToFullyQualifiedBase(sczRootPath, wzCacheId, &sczDefaultCompletedPath);
526
ExitOnFailure(hr, "Failed to construct cache path.");
527
528
hr = PathBackslashTerminate(&sczDefaultCompletedPath);
@@ -957,7 +963,7 @@ extern "C" HRESULT CacheLayoutBundle(
963
HRESULT hr = S_OK;
964
LPWSTR sczTargetPath = NULL;
965
960
- hr = PathConcatRelativeToBase(wzLayoutDirectory, wzExecutableName, &sczTargetPath);
966
+ hr = PathConcatRelativeToFullyQualifiedBase(wzLayoutDirectory, wzExecutableName, &sczTargetPath);
967
ExitOnFailure(hr, "Failed to combine completed path with engine file name for layout.");
968
969
LogStringLine(REPORT_STANDARD, "Layout bundle from: '%ls' to: '%ls'", wzSourceBundlePath, sczTargetPath);
@@ -992,7 +998,7 @@ extern "C" HRESULT CacheCompleteBundle(
998
hr = CreateCompletedPath(pCache, fPerMachine, wzBundleId, NULL, &sczTargetDirectory);
999
ExitOnFailure(hr, "Failed to create completed cache path for bundle.");
1000
995
- hr = PathConcatRelativeToBase(sczTargetDirectory, wzExecutableName, &sczTargetPath);
1001
+ hr = PathConcatRelativeToFullyQualifiedBase(sczTargetDirectory, wzExecutableName, &sczTargetPath);
1002
ExitOnFailure(hr, "Failed to combine completed path with engine file name.");
1003
1004
// We can't just use wzExecutablePath because we needed to call CreateCompletedPath to ensure that the destination was secured.
@@ -1045,7 +1051,7 @@ extern "C" HRESULT CacheLayoutContainer(
1051
HRESULT hr = S_OK;
1052
LPWSTR sczCachedPath = NULL;
1053
1048
- hr = PathConcatRelativeToBase(wzLayoutDirectory, pContainer->sczFilePath, &sczCachedPath);
1054
+ hr = PathConcatRelativeToFullyQualifiedBase(wzLayoutDirectory, pContainer->sczFilePath, &sczCachedPath);
1055
ExitOnFailure(hr, "Failed to concat complete cached path.");
1056
1057
hr = VerifyThenTransferContainer(pContainer, sczCachedPath, wzUnverifiedContainerPath, fMove, pfnCacheMessageHandler, pfnProgress, pContext);
@@ -1070,7 +1076,7 @@ extern "C" HRESULT CacheLayoutPayload(
1076
HRESULT hr = S_OK;
1077
LPWSTR sczCachedPath = NULL;
1078
1073
- hr = PathConcatRelativeToBase(wzLayoutDirectory, pPayload->sczFilePath, &sczCachedPath);
1079
+ hr = PathConcatRelativeToFullyQualifiedBase(wzLayoutDirectory, pPayload->sczFilePath, &sczCachedPath);
1080
ExitOnFailure(hr, "Failed to concat complete cached path.");
1081
1082
hr = VerifyThenTransferPayload(pPayload, sczCachedPath, wzUnverifiedPayloadPath, fMove, pfnCacheMessageHandler, pfnProgress, pContext);
@@ -1165,7 +1171,7 @@ extern "C" HRESULT CacheVerifyContainer(
1171
HRESULT hr = S_OK;
1172
LPWSTR sczCachedPath = NULL;
1173
1168
- hr = PathConcatRelativeToBase(wzCachedDirectory, pContainer->sczFilePath, &sczCachedPath);
1174
+ hr = PathConcatRelativeToFullyQualifiedBase(wzCachedDirectory, pContainer->sczFilePath, &sczCachedPath);
1175
ExitOnFailure(hr, "Failed to concat complete cached path.");
1176
1177
hr = VerifyFileAgainstContainer(pContainer, sczCachedPath, TRUE, BURN_CACHE_STEP_HASH_TO_SKIP_ACQUIRE, pfnCacheMessageHandler, pfnProgress, pContext);
@@ -1187,7 +1193,7 @@ extern "C" HRESULT CacheVerifyPayload(
1193
HRESULT hr = S_OK;
1194
LPWSTR sczCachedPath = NULL;
1195
1190
- hr = PathConcatRelativeToBase(wzCachedDirectory, pPayload->sczFilePath, &sczCachedPath);
1196
+ hr = PathConcatRelativeToFullyQualifiedBase(wzCachedDirectory, pPayload->sczFilePath, &sczCachedPath);
1197
ExitOnFailure(hr, "Failed to concat complete cached path.");
1198
1199
hr = VerifyFileAgainstPayload(pPayload, sczCachedPath, TRUE, BURN_CACHE_STEP_HASH_TO_SKIP_ACQUIRE, pfnCacheMessageHandler, pfnProgress, pContext);
@@ -1478,7 +1484,7 @@ static HRESULT CalculateWorkingFolders(
1484
pCache->wzGuid[GUID_STRING_LENGTH - 1] = L'\\';
1485
pCache->wzGuid[GUID_STRING_LENGTH] = L'\0';
1486
1481
- hr = PathConcatRelativeToBase(sczBaseAcquisitionPath, pCache->wzGuid, &pCache->sczAcquisitionFolder);
1487
+ hr = PathConcatRelativeToFullyQualifiedBase(sczBaseAcquisitionPath, pCache->wzGuid, &pCache->sczAcquisitionFolder);
1488
ExitOnFailure(hr, "Failed to append random guid on to temp path for acquisition folder.");
1489
1490
LExit:
@@ -1626,7 +1632,7 @@ static HRESULT CreateCompletedPath(
1632
else
1633
{
1634
// Get the cache completed file path.
1629
- hr = PathConcatRelativeToBase(sczCacheDirectory, wzFilePath, &sczCacheFile);
1635
+ hr = PathConcatRelativeToFullyQualifiedBase(sczCacheDirectory, wzFilePath, &sczCacheFile);
1636
ExitOnFailure(hr, "Failed to construct cache file.");
1637
1638
// Don't reset permissions here. The payload's package must reset its cache folder when it starts caching.
@@ -1664,7 +1670,7 @@ static HRESULT CreateUnverifiedPath(
1670
pCache->fUnverifiedCacheFolderCreated = TRUE;
1671
}
1672
1667
- hr = PathConcatRelativeToBase(sczUnverifiedCacheFolder, wzPayloadId, psczUnverifiedPayloadPath);
1673
+ hr = PathConcatRelativeToFullyQualifiedBase(sczUnverifiedCacheFolder, wzPayloadId, psczUnverifiedPayloadPath);
1674
ExitOnFailure(hr, "Failed to concat payload id to unverified folder path.");
1675
1676
LExit:
@@ -2085,13 +2091,13 @@ static HRESULT CopyEngineToWorkingFolder(
2091
hr = CacheEnsureBaseWorkingFolder(pCache, &sczWorkingFolder);
2092
ExitOnFailure(hr, "Failed to create working path to copy engine.");
2093
2088
- hr = PathConcatRelativeToBase(sczWorkingFolder, wzWorkingFolderName, &sczTargetDirectory);
2094
+ hr = PathConcatRelativeToFullyQualifiedBase(sczWorkingFolder, wzWorkingFolderName, &sczTargetDirectory);
2095
ExitOnFailure(hr, "Failed to calculate the bundle working folder target name.");
2096
2097
hr = DirEnsureExists(sczTargetDirectory, NULL);
2098
ExitOnFailure(hr, "Failed create bundle working folder.");
2099
2094
- hr = PathConcatRelativeToBase(sczTargetDirectory, wzExecutableName, &sczTargetPath);
2100
+ hr = PathConcatRelativeToFullyQualifiedBase(sczTargetDirectory, wzExecutableName, &sczTargetPath);
2101
ExitOnFailure(hr, "Failed to combine working path with engine file name.");
2102
2103
// Copy the engine without any attached containers to the working path.
src/burn/engine/core.cpp
+1
-1
@@ -2211,7 +2211,7 @@ static HRESULT DetectPackagePayloadsCached(
2211
{
2212
BURN_PAYLOAD* pPayload = pPackage->payloads.rgItems[i].pPayload;
2213
2214
- hr = PathConcatRelativeToBase(sczCachePath, pPayload->sczFilePath, &sczPayloadCachePath);
2214
+ hr = PathConcatRelativeToFullyQualifiedBase(sczCachePath, pPayload->sczFilePath, &sczPayloadCachePath);
2215
ExitOnFailure(hr, "Failed to concat payload cache path.");
2216
2217
if (FileExistsEx(sczPayloadCachePath, NULL))
src/burn/engine/engine.mc
+7
@@ -163,6 +163,13 @@ Language=English
163
Failed to use folder as base working folder: %2!ls!, encountered error: %1!ls!.
164
.
165
166
+MessageId=20
167
+Severity=Warning
168
+SymbolicName=MSG_INVALID_POLICY_MACHINE_PACKAGE_CACHE
169
+Language=English
170
+Failed to use folder as machine package cache: %2!ls!, encountered error: %1!ls!.
171
+.
172
+
173
MessageId=51
174
Severity=Error
175
SymbolicName=MSG_FAILED_PARSE_CONDITION
src/burn/engine/exeengine.cpp
+1
-1
@@ -380,7 +380,7 @@ extern "C" HRESULT ExeEngineExecutePackage(
380
hr = CacheGetCompletedPath(pCache, pPackage->fPerMachine, pPackage->sczCacheId, &sczCachedDirectory);
381
ExitOnFailure(hr, "Failed to get cached path for package: %ls", pPackage->sczId);
382
383
- hr = PathConcatRelativeToBase(sczCachedDirectory, pPackagePayload->sczFilePath, &sczExecutablePath);
383
+ hr = PathConcatRelativeToFullyQualifiedBase(sczCachedDirectory, pPackagePayload->sczFilePath, &sczExecutablePath);
384
ExitOnFailure(hr, "Failed to build executable path.");
385
}
386
src/burn/engine/msiengine.cpp
+2
-2
@@ -1236,7 +1236,7 @@ extern "C" HRESULT MsiEngineExecutePackage(
1236
// Best effort to set the execute package cache folder variable.
1237
VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, sczCachedDirectory, TRUE, FALSE);
1238
1239
- hr = PathConcatRelativeToBase(sczCachedDirectory, pPackagePayload->sczFilePath, &sczMsiPath);
1239
+ hr = PathConcatRelativeToFullyQualifiedBase(sczCachedDirectory, pPackagePayload->sczFilePath, &sczMsiPath);
1240
ExitOnFailure(hr, "Failed to build MSI path.");
1241
}
1242
@@ -2195,7 +2195,7 @@ static HRESULT ConcatPatchProperty(
2195
hr = CacheGetCompletedPath(pCache, pMspPackage->fPerMachine, pMspPackage->sczCacheId, &sczCachedDirectory);
2196
ExitOnFailure(hr, "Failed to get cached path for MSP package: %ls", pMspPackage->sczId);
2197
2198
- hr = PathConcatRelativeToBase(sczCachedDirectory, pMspPackagePayload->sczFilePath, &sczMspPath);
2198
+ hr = PathConcatRelativeToFullyQualifiedBase(sczCachedDirectory, pMspPackagePayload->sczFilePath, &sczMspPath);
2199
ExitOnFailure(hr, "Failed to build MSP path.");
2200
2201
if (!sczPatches)
src/burn/engine/mspengine.cpp
+1
-1
@@ -613,7 +613,7 @@ extern "C" HRESULT MspEngineExecutePackage(
613
// Best effort to set the execute package cache folder variable.
614
VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, sczCachedDirectory, TRUE, FALSE);
615
616
- hr = PathConcatRelativeToBase(sczCachedDirectory, pMspPackagePayload->sczFilePath, &sczMspPath);
616
+ hr = PathConcatRelativeToFullyQualifiedBase(sczCachedDirectory, pMspPackagePayload->sczFilePath, &sczMspPath);
617
ExitOnFailure(hr, "Failed to build MSP path.");
618
619
wzAppend = sczMspPath;
src/burn/engine/msuengine.cpp
+1
-1
@@ -320,7 +320,7 @@ extern "C" HRESULT MsuEngineExecutePackage(
320
// Best effort to set the execute package cache folder variable.
321
VariableSetString(pVariables, BURN_BUNDLE_EXECUTE_PACKAGE_CACHE_FOLDER, sczCachedDirectory, TRUE, FALSE);
322
323
- hr = PathConcatRelativeToBase(sczCachedDirectory, pPackagePayload->sczFilePath, &sczMsuPath);
323
+ hr = PathConcatRelativeToFullyQualifiedBase(sczCachedDirectory, pPackagePayload->sczFilePath, &sczMsuPath);
324
ExitOnFailure(hr, "Failed to build MSU path.");
325
326
// format command
src/burn/engine/payload.cpp
+1
-1
@@ -294,7 +294,7 @@ extern "C" HRESULT PayloadExtractUXContainer(
294
ExitOnFailure(hr, "Failed to find embedded payload: %ls", sczStreamName);
295
296
// make file path
297
- hr = PathConcatRelativeToBase(wzTargetDir, pPayload->sczFilePath, &pPayload->sczLocalFilePath);
297
+ hr = PathConcatRelativeToFullyQualifiedBase(wzTargetDir, pPayload->sczFilePath, &pPayload->sczLocalFilePath);
298
ExitOnFailure(hr, "Failed to concat file paths.");
299
300
// extract file
src/burn/engine/plan.cpp
+8
-3
@@ -432,24 +432,28 @@ extern "C" HRESULT PlanLayoutBundle(
432
{
433
HRESULT hr = S_OK;
434
BURN_CACHE_ACTION* pCacheAction = NULL;
435
+ LPWSTR sczLayoutDirectory = NULL;
436
LPWSTR sczExecutablePath = NULL;
437
438
// Get the layout directory.
438
- hr = VariableGetString(pVariables, BURN_BUNDLE_LAYOUT_DIRECTORY, &pPlan->sczLayoutDirectory);
439
+ hr = VariableGetString(pVariables, BURN_BUNDLE_LAYOUT_DIRECTORY, &sczLayoutDirectory);
440
if (E_NOTFOUND == hr) // if not set, use the current directory as the layout directory.
441
{
441
- hr = VariableGetString(pVariables, BURN_BUNDLE_SOURCE_PROCESS_FOLDER, &pPlan->sczLayoutDirectory);
442
+ hr = VariableGetString(pVariables, BURN_BUNDLE_SOURCE_PROCESS_FOLDER, &sczLayoutDirectory);
443
if (E_NOTFOUND == hr) // if not set, use the current directory as the layout directory.
444
{
445
hr = PathForCurrentProcess(&sczExecutablePath, NULL);
446
ExitOnFailure(hr, "Failed to get path for current executing process as layout directory.");
447
447
- hr = PathGetDirectory(sczExecutablePath, &pPlan->sczLayoutDirectory);
448
+ hr = PathGetDirectory(sczExecutablePath, &sczLayoutDirectory);
449
ExitOnFailure(hr, "Failed to get executing process as layout directory.");
450
}
451
}
452
ExitOnFailure(hr, "Failed to get bundle layout directory property.");
453
454
+ hr = PathGetFullPathName(sczLayoutDirectory, &pPlan->sczLayoutDirectory, NULL, NULL);
455
+ ExitOnFailure(hr, "Failed to ensure layout directory is fully qualified.");
456
+
457
hr = PathBackslashTerminate(&pPlan->sczLayoutDirectory);
458
ExitOnFailure(hr, "Failed to ensure layout directory is backslash terminated.");
459
@@ -478,6 +482,7 @@ extern "C" HRESULT PlanLayoutBundle(
482
483
LExit:
484
ReleaseStr(sczExecutablePath);
485
+ ReleaseStr(sczLayoutDirectory);
486
487
return hr;
488
}
src/burn/engine/registration.cpp
+3
-3
@@ -1149,7 +1149,7 @@ static HRESULT SetPaths(
1149
ExitOnFailure(hr, "Failed to build cache directory.");
1150
1151
// build cached executable path
1152
- hr = PathConcatRelativeToBase(sczCacheDirectory, pRegistration->sczExecutableName, &pRegistration->sczCacheExecutablePath);
1152
+ hr = PathConcatRelativeToFullyQualifiedBase(sczCacheDirectory, pRegistration->sczExecutableName, &pRegistration->sczCacheExecutablePath);
1153
ExitOnFailure(hr, "Failed to build cached executable path.");
1154
1155
// build state file path
@@ -1367,7 +1367,7 @@ static HRESULT WriteSoftwareTags(
1367
hr = PathConcat(sczRootFolder, SWIDTAG_FOLDER, &sczTagFolder);
1368
ExitOnFailure(hr, "Failed to allocate regid folder path.");
1369
1370
- hr = PathConcatRelativeToBase(sczTagFolder, pSoftwareTag->sczFilename, &sczPath);
1370
+ hr = PathConcatRelativeToFullyQualifiedBase(sczTagFolder, pSoftwareTag->sczFilename, &sczPath);
1371
ExitOnFailure(hr, "Failed to allocate regid file path.");
1372
1373
hr = DirEnsureExists(sczTagFolder, NULL);
@@ -1405,7 +1405,7 @@ static HRESULT RemoveSoftwareTags(
1405
hr = PathConcat(sczRootFolder, SWIDTAG_FOLDER, &sczTagFolder);
1406
ExitOnFailure(hr, "Failed to allocate regid folder path.");
1407
1408
- hr = PathConcatRelativeToBase(sczTagFolder, pSoftwareTag->sczFilename, &sczPath);
1408
+ hr = PathConcatRelativeToFullyQualifiedBase(sczTagFolder, pSoftwareTag->sczFilename, &sczPath);
1409
ExitOnFailure(hr, "Failed to allocate regid file path.");
1410
1411
// Best effort to delete the software tag file and the regid folder.
src/libs/dutil/WixToolset.DUtil/inc/pathutil.h
+10
@@ -298,6 +298,16 @@ DAPI_(HRESULT) PathConcatRelativeToBase(
298
__deref_out_z LPWSTR* psczCombined
299
);
300
301
+/*******************************************************************
302
+ PathConcatRelativeToFullyQualifiedBase - ensures the base path is
303
+ fully qualified and then calls PathConcatRelativeToBase.
304
+*******************************************************************/
305
+DAPI_(HRESULT) PathConcatRelativeToFullyQualifiedBase(
306
+ __in LPCWSTR wzBase,
307
+ __in_opt LPCWSTR wzRelative,
308
+ __deref_out_z LPWSTR* psczCombined
309
+ );
310
+
311
/*******************************************************************
312
PathCompareCanonicalized - canonicalizes the two paths using PathCanonicalizeForComparison
313
which does not resolve relative paths into fully qualified paths.
src/libs/dutil/WixToolset.DUtil/path2utl.cpp
+19
@@ -162,6 +162,25 @@ LExit:
162
return hr;
163
}
164
165
+DAPI_(HRESULT) PathConcatRelativeToFullyQualifiedBase(
166
+ __in LPCWSTR wzBase,
167
+ __in_opt LPCWSTR wzRelative,
168
+ __deref_out_z LPWSTR* psczCombined
169
+ )
170
+{
171
+ HRESULT hr = S_OK;
172
+
173
+ if (!PathIsFullyQualified(wzBase))
174
+ {
175
+ PathExitWithRootFailure(hr, E_INVALIDARG, "wzBase must be fully qualified: %ls.", wzBase);
176
+ }
177
+
178
+ hr = PathConcatRelativeToBase(wzBase, wzRelative, psczCombined);
179
+
180
+LExit:
181
+ return hr;
182
+}
183
+
184
DAPI_(HRESULT) PathCompareCanonicalized(
185
__in_z LPCWSTR wzPath1,
186
__in_z LPCWSTR wzPath2,