From 914a92d16d7a0245f3cf0b42cc5e320c34d23d30 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Wed, 31 Aug 2022 16:07:08 -0400 Subject: Supply hashes to BA if present in update feed. Fixes https://github.com/wixtoolset/issues/issues/6353. --- src/burn/engine/detect.cpp | 24 ++++++++++++++++++++---- src/burn/engine/userexperience.cpp | 5 +++++ src/burn/engine/userexperience.h | 2 ++ 3 files changed, 27 insertions(+), 4 deletions(-) (limited to 'src/burn') diff --git a/src/burn/engine/detect.cpp b/src/burn/engine/detect.cpp index 7628b26a..25d184c1 100644 --- a/src/burn/engine/detect.cpp +++ b/src/burn/engine/detect.cpp @@ -379,6 +379,7 @@ static HRESULT DetectAtomFeedUpdate( ATOM_FEED* pAtomFeed = NULL; APPLICATION_UPDATE_CHAIN* pApupChain = NULL; BOOL fStopProcessingUpdates = FALSE; + LPWSTR sczHash = NULL; hr = AtomInitialize(); ExitOnFailure(hr, "Failed to initialize Atom."); @@ -397,11 +398,25 @@ static HRESULT DetectAtomFeedUpdate( for (DWORD i = 0; i < pApupChain->cEntries; ++i) { APPLICATION_UPDATE_ENTRY* pAppUpdateEntry = &pApupChain->rgEntries[i]; + APPLICATION_UPDATE_ENCLOSURE* pEnclosure = pAppUpdateEntry->rgEnclosures; - hr = UserExperienceOnDetectUpdate(pUX, pAppUpdateEntry->rgEnclosures ? pAppUpdateEntry->rgEnclosures->wzUrl : NULL, - pAppUpdateEntry->rgEnclosures ? pAppUpdateEntry->rgEnclosures->dw64Size : 0, - pAppUpdateEntry->pVersion, pAppUpdateEntry->wzTitle, - pAppUpdateEntry->wzSummary, pAppUpdateEntry->wzContentType, pAppUpdateEntry->wzContent, &fStopProcessingUpdates); + if (pEnclosure) + { + hr = StrAllocHexEncode(pEnclosure->rgbDigest, pEnclosure->cbDigest, &sczHash); + ExitOnFailure(hr, "Failed to encode hash as string."); + } + + hr = UserExperienceOnDetectUpdate(pUX, + pEnclosure ? pEnclosure->wzUrl : NULL, + pEnclosure ? pEnclosure->dw64Size : 0, + sczHash ? sczHash : L"", + pEnclosure ? pEnclosure->digestAlgorithm == APUP_HASH_ALGORITHM_SHA512 ? BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 : BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE : BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE, + pAppUpdateEntry->pVersion, + pAppUpdateEntry->wzTitle, + pAppUpdateEntry->wzSummary, + pAppUpdateEntry->wzContentType, + pAppUpdateEntry->wzContent, + &fStopProcessingUpdates); ExitOnRootFailure(hr, "BA aborted detect update."); if (fStopProcessingUpdates) @@ -420,6 +435,7 @@ LExit: ApupFreeChain(pApupChain); AtomFreeFeed(pAtomFeed); ReleaseStr(sczUpdateFeedTempFile); + ReleaseStr(sczHash); AtomUninitialize(); return hr; diff --git a/src/burn/engine/userexperience.cpp b/src/burn/engine/userexperience.cpp index 6f84caba..28429394 100644 --- a/src/burn/engine/userexperience.cpp +++ b/src/burn/engine/userexperience.cpp @@ -1395,6 +1395,8 @@ EXTERN_C BAAPI UserExperienceOnDetectUpdate( __in BURN_USER_EXPERIENCE* pUserExperience, __in_z_opt LPCWSTR wzUpdateLocation, __in DWORD64 dw64Size, + __in_z_opt LPCWSTR wzHash, + __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashAlgorithm, __in VERUTIL_VERSION* pVersion, __in_z_opt LPCWSTR wzTitle, __in_z_opt LPCWSTR wzSummary, @@ -1410,6 +1412,8 @@ EXTERN_C BAAPI UserExperienceOnDetectUpdate( args.cbSize = sizeof(args); args.wzUpdateLocation = wzUpdateLocation; args.dw64Size = dw64Size; + args.wzHash = wzHash; + args.hashAlgorithm = hashAlgorithm; args.wzVersion = pVersion->sczVersion; args.wzTitle = wzTitle; args.wzSummary = wzSummary; @@ -1426,6 +1430,7 @@ EXTERN_C BAAPI UserExperienceOnDetectUpdate( { hr = HRESULT_FROM_WIN32(ERROR_INSTALL_USEREXIT); } + *pfStopProcessingUpdates = results.fStopProcessingUpdates; LExit: diff --git a/src/burn/engine/userexperience.h b/src/burn/engine/userexperience.h index 9f183208..e342da03 100644 --- a/src/burn/engine/userexperience.h +++ b/src/burn/engine/userexperience.h @@ -332,6 +332,8 @@ BAAPI UserExperienceOnDetectUpdate( __in BURN_USER_EXPERIENCE* pUserExperience, __in_z_opt LPCWSTR wzUpdateLocation, __in DWORD64 dw64Size, + __in_z_opt LPCWSTR wzHash, + __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashAlgorithm, __in VERUTIL_VERSION* pVersion, __in_z_opt LPCWSTR wzTitle, __in_z_opt LPCWSTR wzSummary, -- cgit v1.2.3-55-g6feb