From 6a45cb7687de57056532fe897a708435deec2ea3 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Fri, 9 Sep 2022 21:21:55 -0400 Subject: Update hashes are now hex strings. Fixes https://github.com/wixtoolset/issues/issues/6901. --- src/burn/engine/EngineForApplication.cpp | 2 +- src/burn/engine/externalengine.cpp | 9 ++++----- src/burn/engine/externalengine.h | 5 ++--- src/burn/engine/pseudobundle.cpp | 16 +++++++++++----- src/burn/engine/pseudobundle.h | 5 ++--- 5 files changed, 20 insertions(+), 17 deletions(-) (limited to 'src/burn') diff --git a/src/burn/engine/EngineForApplication.cpp b/src/burn/engine/EngineForApplication.cpp index 83d88ba1..27f815c6 100644 --- a/src/burn/engine/EngineForApplication.cpp +++ b/src/burn/engine/EngineForApplication.cpp @@ -197,7 +197,7 @@ static HRESULT BAEngineSetUpdate( ValidateMessageArgs(hr, pvArgs, BAENGINE_SETUPDATE_ARGS, pArgs); ValidateMessageResults(hr, pvResults, BAENGINE_SETUPDATE_RESULTS, pResults); - hr = ExternalEngineSetUpdate(pContext->pEngineState, pArgs->wzLocalSource, pArgs->wzDownloadSource, pArgs->qwSize, pArgs->hashType, pArgs->rgbHash, pArgs->cbHash); + hr = ExternalEngineSetUpdate(pContext->pEngineState, pArgs->wzLocalSource, pArgs->wzDownloadSource, pArgs->qwSize, pArgs->hashType, pArgs->wzHash); LExit: return hr; diff --git a/src/burn/engine/externalengine.cpp b/src/burn/engine/externalengine.cpp index 16977395..e18b9486 100644 --- a/src/burn/engine/externalengine.cpp +++ b/src/burn/engine/externalengine.cpp @@ -269,8 +269,7 @@ HRESULT ExternalEngineSetUpdate( __in_z_opt LPCWSTR wzDownloadSource, __in const DWORD64 qwSize, __in const BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, - __in_opt const BYTE* rgbHash, - __in const DWORD cbHash + __in_opt LPCWSTR wzHash ) { HRESULT hr = S_OK; @@ -293,11 +292,11 @@ HRESULT ExternalEngineSetUpdate( if (!fRemove) { - if (BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE == hashType && (0 != cbHash || rgbHash)) + if (BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE == hashType && wzHash && *wzHash) { ExitFunction1(hr = E_INVALIDARG); } - else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 == hashType && (SHA512_HASH_LEN != cbHash || !rgbHash)) + else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 == hashType && (!wzHash || !*wzHash || SHA512_HASH_LEN != lstrlenW(wzHash))) { ExitFunction1(hr = E_INVALIDARG); } @@ -335,7 +334,7 @@ HRESULT ExternalEngineSetUpdate( wzLocalSource = sczFilePath; } - hr = PseudoBundleInitializeUpdateBundle(&pEngineState->update.package, wzGuid, pEngineState->registration.sczId, sczFilePath, wzLocalSource, wzDownloadSource, qwSize, sczCommandline, rgbHash, cbHash); + hr = PseudoBundleInitializeUpdateBundle(&pEngineState->update.package, wzGuid, pEngineState->registration.sczId, sczFilePath, wzLocalSource, wzDownloadSource, qwSize, sczCommandline, wzHash); ExitOnFailure(hr, "Failed to set update bundle."); pEngineState->update.fUpdateAvailable = TRUE; diff --git a/src/burn/engine/externalengine.h b/src/burn/engine/externalengine.h index 2903615d..f28971cd 100644 --- a/src/burn/engine/externalengine.h +++ b/src/burn/engine/externalengine.h @@ -81,9 +81,8 @@ HRESULT ExternalEngineSetUpdate( __in_z_opt LPCWSTR wzDownloadSource, __in const DWORD64 qwSize, __in const BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, - __in_opt const BYTE* rgbHash, - __in const DWORD cbHash - ); + __in_opt LPCWSTR wzHash +); HRESULT ExternalEngineSetLocalSource( __in BURN_ENGINE_STATE* pEngineState, diff --git a/src/burn/engine/pseudobundle.cpp b/src/burn/engine/pseudobundle.cpp index 082c4487..8b30ebfc 100644 --- a/src/burn/engine/pseudobundle.cpp +++ b/src/burn/engine/pseudobundle.cpp @@ -142,9 +142,8 @@ extern "C" HRESULT PseudoBundleInitializeUpdateBundle( __in_z_opt LPCWSTR wzDownloadSource, __in DWORD64 qwSize, __in_z LPCWSTR wzInstallArguments, - __in_opt const BYTE* pbHash, - __in const DWORD cbHash - ) + __in_opt LPCWSTR wzHash +) { HRESULT hr = S_OK; BURN_PAYLOAD* pPayload = NULL; @@ -176,13 +175,20 @@ extern "C" HRESULT PseudoBundleInitializeUpdateBundle( ExitOnFailure(hr, "Failed to copy download source for pseudo bundle."); } - if (pbHash) + if (wzHash && *wzHash) { + BYTE* rgbHash = NULL; + DWORD cbHash = 0; + + hr = StrAllocHexDecode(wzHash, &rgbHash, &cbHash); + ExitOnFailure(hr, "Failed to decode hash string: %ls.", wzHash); + pPayload->pbHash = static_cast(MemAlloc(cbHash, FALSE)); ExitOnNull(pPayload->pbHash, hr, E_OUTOFMEMORY, "Failed to allocate memory for update bundle payload hash."); pPayload->cbHash = cbHash; - memcpy_s(pPayload->pbHash, pPayload->cbHash, pbHash, cbHash); + + memcpy_s(pPayload->pbHash, pPayload->cbHash, rgbHash, cbHash); } pPackage->type = BURN_PACKAGE_TYPE_EXE; diff --git a/src/burn/engine/pseudobundle.h b/src/burn/engine/pseudobundle.h index 78a681df..e55bb951 100644 --- a/src/burn/engine/pseudobundle.h +++ b/src/burn/engine/pseudobundle.h @@ -34,9 +34,8 @@ HRESULT PseudoBundleInitializeUpdateBundle( __in_z_opt LPCWSTR wzDownloadSource, __in DWORD64 qwSize, __in_z LPCWSTR wzInstallArguments, - __in_opt const BYTE* pbHash, - __in const DWORD cbHash - ); + __in_opt LPCWSTR wzHash +); #if defined(__cplusplus) } -- cgit v1.2.3-55-g6feb