aboutsummaryrefslogtreecommitdiff
path: root/src/burn
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2022-09-09 21:21:55 -0400
committerBob Arnson <github@bobs.org>2022-09-12 13:33:03 -0400
commit6a45cb7687de57056532fe897a708435deec2ea3 (patch)
treea9795ac837d0475ea22d86c0d592fac7b0b6c159 /src/burn
parenta1307cd4e76a89598c53cb68309358a7012db553 (diff)
downloadwix-6a45cb7687de57056532fe897a708435deec2ea3.tar.gz
wix-6a45cb7687de57056532fe897a708435deec2ea3.tar.bz2
wix-6a45cb7687de57056532fe897a708435deec2ea3.zip
Update hashes are now hex strings.
Fixes https://github.com/wixtoolset/issues/issues/6901.
Diffstat (limited to 'src/burn')
-rw-r--r--src/burn/engine/EngineForApplication.cpp2
-rw-r--r--src/burn/engine/externalengine.cpp9
-rw-r--r--src/burn/engine/externalengine.h5
-rw-r--r--src/burn/engine/pseudobundle.cpp16
-rw-r--r--src/burn/engine/pseudobundle.h5
5 files changed, 20 insertions, 17 deletions
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(
197 ValidateMessageArgs(hr, pvArgs, BAENGINE_SETUPDATE_ARGS, pArgs); 197 ValidateMessageArgs(hr, pvArgs, BAENGINE_SETUPDATE_ARGS, pArgs);
198 ValidateMessageResults(hr, pvResults, BAENGINE_SETUPDATE_RESULTS, pResults); 198 ValidateMessageResults(hr, pvResults, BAENGINE_SETUPDATE_RESULTS, pResults);
199 199
200 hr = ExternalEngineSetUpdate(pContext->pEngineState, pArgs->wzLocalSource, pArgs->wzDownloadSource, pArgs->qwSize, pArgs->hashType, pArgs->rgbHash, pArgs->cbHash); 200 hr = ExternalEngineSetUpdate(pContext->pEngineState, pArgs->wzLocalSource, pArgs->wzDownloadSource, pArgs->qwSize, pArgs->hashType, pArgs->wzHash);
201 201
202LExit: 202LExit:
203 return hr; 203 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(
269 __in_z_opt LPCWSTR wzDownloadSource, 269 __in_z_opt LPCWSTR wzDownloadSource,
270 __in const DWORD64 qwSize, 270 __in const DWORD64 qwSize,
271 __in const BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, 271 __in const BOOTSTRAPPER_UPDATE_HASH_TYPE hashType,
272 __in_opt const BYTE* rgbHash, 272 __in_opt LPCWSTR wzHash
273 __in const DWORD cbHash
274 ) 273 )
275{ 274{
276 HRESULT hr = S_OK; 275 HRESULT hr = S_OK;
@@ -293,11 +292,11 @@ HRESULT ExternalEngineSetUpdate(
293 292
294 if (!fRemove) 293 if (!fRemove)
295 { 294 {
296 if (BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE == hashType && (0 != cbHash || rgbHash)) 295 if (BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE == hashType && wzHash && *wzHash)
297 { 296 {
298 ExitFunction1(hr = E_INVALIDARG); 297 ExitFunction1(hr = E_INVALIDARG);
299 } 298 }
300 else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 == hashType && (SHA512_HASH_LEN != cbHash || !rgbHash)) 299 else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 == hashType && (!wzHash || !*wzHash || SHA512_HASH_LEN != lstrlenW(wzHash)))
301 { 300 {
302 ExitFunction1(hr = E_INVALIDARG); 301 ExitFunction1(hr = E_INVALIDARG);
303 } 302 }
@@ -335,7 +334,7 @@ HRESULT ExternalEngineSetUpdate(
335 wzLocalSource = sczFilePath; 334 wzLocalSource = sczFilePath;
336 } 335 }
337 336
338 hr = PseudoBundleInitializeUpdateBundle(&pEngineState->update.package, wzGuid, pEngineState->registration.sczId, sczFilePath, wzLocalSource, wzDownloadSource, qwSize, sczCommandline, rgbHash, cbHash); 337 hr = PseudoBundleInitializeUpdateBundle(&pEngineState->update.package, wzGuid, pEngineState->registration.sczId, sczFilePath, wzLocalSource, wzDownloadSource, qwSize, sczCommandline, wzHash);
339 ExitOnFailure(hr, "Failed to set update bundle."); 338 ExitOnFailure(hr, "Failed to set update bundle.");
340 339
341 pEngineState->update.fUpdateAvailable = TRUE; 340 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(
81 __in_z_opt LPCWSTR wzDownloadSource, 81 __in_z_opt LPCWSTR wzDownloadSource,
82 __in const DWORD64 qwSize, 82 __in const DWORD64 qwSize,
83 __in const BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, 83 __in const BOOTSTRAPPER_UPDATE_HASH_TYPE hashType,
84 __in_opt const BYTE* rgbHash, 84 __in_opt LPCWSTR wzHash
85 __in const DWORD cbHash 85);
86 );
87 86
88HRESULT ExternalEngineSetLocalSource( 87HRESULT ExternalEngineSetLocalSource(
89 __in BURN_ENGINE_STATE* pEngineState, 88 __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(
142 __in_z_opt LPCWSTR wzDownloadSource, 142 __in_z_opt LPCWSTR wzDownloadSource,
143 __in DWORD64 qwSize, 143 __in DWORD64 qwSize,
144 __in_z LPCWSTR wzInstallArguments, 144 __in_z LPCWSTR wzInstallArguments,
145 __in_opt const BYTE* pbHash, 145 __in_opt LPCWSTR wzHash
146 __in const DWORD cbHash 146)
147 )
148{ 147{
149 HRESULT hr = S_OK; 148 HRESULT hr = S_OK;
150 BURN_PAYLOAD* pPayload = NULL; 149 BURN_PAYLOAD* pPayload = NULL;
@@ -176,13 +175,20 @@ extern "C" HRESULT PseudoBundleInitializeUpdateBundle(
176 ExitOnFailure(hr, "Failed to copy download source for pseudo bundle."); 175 ExitOnFailure(hr, "Failed to copy download source for pseudo bundle.");
177 } 176 }
178 177
179 if (pbHash) 178 if (wzHash && *wzHash)
180 { 179 {
180 BYTE* rgbHash = NULL;
181 DWORD cbHash = 0;
182
183 hr = StrAllocHexDecode(wzHash, &rgbHash, &cbHash);
184 ExitOnFailure(hr, "Failed to decode hash string: %ls.", wzHash);
185
181 pPayload->pbHash = static_cast<BYTE*>(MemAlloc(cbHash, FALSE)); 186 pPayload->pbHash = static_cast<BYTE*>(MemAlloc(cbHash, FALSE));
182 ExitOnNull(pPayload->pbHash, hr, E_OUTOFMEMORY, "Failed to allocate memory for update bundle payload hash."); 187 ExitOnNull(pPayload->pbHash, hr, E_OUTOFMEMORY, "Failed to allocate memory for update bundle payload hash.");
183 188
184 pPayload->cbHash = cbHash; 189 pPayload->cbHash = cbHash;
185 memcpy_s(pPayload->pbHash, pPayload->cbHash, pbHash, cbHash); 190
191 memcpy_s(pPayload->pbHash, pPayload->cbHash, rgbHash, cbHash);
186 } 192 }
187 193
188 pPackage->type = BURN_PACKAGE_TYPE_EXE; 194 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(
34 __in_z_opt LPCWSTR wzDownloadSource, 34 __in_z_opt LPCWSTR wzDownloadSource,
35 __in DWORD64 qwSize, 35 __in DWORD64 qwSize,
36 __in_z LPCWSTR wzInstallArguments, 36 __in_z LPCWSTR wzInstallArguments,
37 __in_opt const BYTE* pbHash, 37 __in_opt LPCWSTR wzHash
38 __in const DWORD cbHash 38);
39 );
40 39
41#if defined(__cplusplus) 40#if defined(__cplusplus)
42} 41}