diff options
author | Rob Mensching <rob@firegiant.com> | 2025-02-11 05:21:34 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2025-02-11 15:49:33 -0800 |
commit | f2e9af96142439ebfdbc1e884335bb8874f8a427 (patch) | |
tree | f3ffd15660a7041d1f70d793e2b2200ccbe42af5 /src/burn/engine/payload.cpp | |
parent | 81fb512834c65b0a8f99c3a266879c476e382875 (diff) | |
download | wix-f2e9af96142439ebfdbc1e884335bb8874f8a427.tar.gz wix-f2e9af96142439ebfdbc1e884335bb8874f8a427.tar.bz2 wix-f2e9af96142439ebfdbc1e884335bb8874f8a427.zip |
Harden Burn's BootstrapperApplication and elevated engine extraction
Fixes 8914
Diffstat (limited to 'src/burn/engine/payload.cpp')
-rw-r--r-- | src/burn/engine/payload.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/burn/engine/payload.cpp b/src/burn/engine/payload.cpp index 1d8328e3..270da6aa 100644 --- a/src/burn/engine/payload.cpp +++ b/src/burn/engine/payload.cpp | |||
@@ -239,6 +239,7 @@ extern "C" void PayloadUninitialize( | |||
239 | ReleaseMem(pPayload->pbCertificateRootThumbprint); | 239 | ReleaseMem(pPayload->pbCertificateRootThumbprint); |
240 | ReleaseMem(pPayload->pbCertificateRootPublicKeyIdentifier); | 240 | ReleaseMem(pPayload->pbCertificateRootPublicKeyIdentifier); |
241 | ReleaseStr(pPayload->sczSourcePath); | 241 | ReleaseStr(pPayload->sczSourcePath); |
242 | ReleaseFileHandle(pPayload->hLocalFile); | ||
242 | ReleaseStr(pPayload->sczLocalFilePath); | 243 | ReleaseStr(pPayload->sczLocalFilePath); |
243 | ReleaseStr(pPayload->sczFailedLocalAcquisitionPath); | 244 | ReleaseStr(pPayload->sczFailedLocalAcquisitionPath); |
244 | ReleaseStr(pPayload->downloadSource.sczUrl); | 245 | ReleaseStr(pPayload->downloadSource.sczUrl); |
@@ -278,6 +279,7 @@ extern "C" HRESULT PayloadExtractUXContainer( | |||
278 | LPWSTR sczStreamName = NULL; | 279 | LPWSTR sczStreamName = NULL; |
279 | LPWSTR sczDirectory = NULL; | 280 | LPWSTR sczDirectory = NULL; |
280 | BURN_PAYLOAD* pPayload = NULL; | 281 | BURN_PAYLOAD* pPayload = NULL; |
282 | HANDLE hTargetFile = INVALID_HANDLE_VALUE; | ||
281 | 283 | ||
282 | // extract all payloads | 284 | // extract all payloads |
283 | for (;;) | 285 | for (;;) |
@@ -306,9 +308,18 @@ extern "C" HRESULT PayloadExtractUXContainer( | |||
306 | hr = DirEnsureExists(sczDirectory, NULL); | 308 | hr = DirEnsureExists(sczDirectory, NULL); |
307 | ExitOnFailure(hr, "Failed to ensure directory exists"); | 309 | ExitOnFailure(hr, "Failed to ensure directory exists"); |
308 | 310 | ||
309 | hr = ContainerStreamToFile(pContainerContext, pPayload->sczLocalFilePath); | 311 | hTargetFile = ::CreateFileW(pPayload->sczLocalFilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); |
312 | ExitOnInvalidHandleWithLastError(hTargetFile, hr, "Failed to create file: %ls", pPayload->sczLocalFilePath); | ||
313 | |||
314 | hr = ContainerStreamToHandle(pContainerContext, hTargetFile); | ||
310 | ExitOnFailure(hr, "Failed to extract file."); | 315 | ExitOnFailure(hr, "Failed to extract file."); |
311 | 316 | ||
317 | // Reopen the payload for read-only access to prevent the file from being removed or tampered with while the BA is running. | ||
318 | ReleaseFileHandle(hTargetFile); | ||
319 | |||
320 | hr = FileCreateWithRetry(pPayload->sczLocalFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 30, 100, &pPayload->hLocalFile); | ||
321 | ExitOnFailure(hr, "Failed to open file: %ls", pPayload->sczLocalFilePath); | ||
322 | |||
312 | // flag that the payload has been acquired | 323 | // flag that the payload has been acquired |
313 | pPayload->state = BURN_PAYLOAD_STATE_ACQUIRED; | 324 | pPayload->state = BURN_PAYLOAD_STATE_ACQUIRED; |
314 | } | 325 | } |
@@ -326,6 +337,7 @@ extern "C" HRESULT PayloadExtractUXContainer( | |||
326 | } | 337 | } |
327 | 338 | ||
328 | LExit: | 339 | LExit: |
340 | ReleaseFileHandle(hTargetFile); | ||
329 | ReleaseStr(sczStreamName); | 341 | ReleaseStr(sczStreamName); |
330 | ReleaseStr(sczDirectory); | 342 | ReleaseStr(sczDirectory); |
331 | 343 | ||