diff options
author | Bob Arnson <bob@firegiant.com> | 2022-09-09 21:21:55 -0400 |
---|---|---|
committer | Bob Arnson <github@bobs.org> | 2022-09-12 13:33:03 -0400 |
commit | 6a45cb7687de57056532fe897a708435deec2ea3 (patch) | |
tree | a9795ac837d0475ea22d86c0d592fac7b0b6c159 | |
parent | a1307cd4e76a89598c53cb68309358a7012db553 (diff) | |
download | wix-6a45cb7687de57056532fe897a708435deec2ea3.tar.gz wix-6a45cb7687de57056532fe897a708435deec2ea3.tar.bz2 wix-6a45cb7687de57056532fe897a708435deec2ea3.zip |
Update hashes are now hex strings.
Fixes https://github.com/wixtoolset/issues/issues/6901.
-rw-r--r-- | src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h | 3 | ||||
-rw-r--r-- | src/api/burn/WixToolset.Mba.Core/Engine.cs | 4 | ||||
-rw-r--r-- | src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs | 8 | ||||
-rw-r--r-- | src/api/burn/WixToolset.Mba.Core/IEngine.cs | 2 | ||||
-rw-r--r-- | src/api/burn/balutil/BalBootstrapperEngine.cpp | 6 | ||||
-rw-r--r-- | src/api/burn/balutil/inc/IBootstrapperEngine.h | 3 | ||||
-rw-r--r-- | src/burn/engine/EngineForApplication.cpp | 2 | ||||
-rw-r--r-- | src/burn/engine/externalengine.cpp | 9 | ||||
-rw-r--r-- | src/burn/engine/externalengine.h | 5 | ||||
-rw-r--r-- | src/burn/engine/pseudobundle.cpp | 16 | ||||
-rw-r--r-- | src/burn/engine/pseudobundle.h | 5 |
11 files changed, 30 insertions, 33 deletions
diff --git a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h index cdb01330..941e4241 100644 --- a/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h +++ b/src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h | |||
@@ -381,8 +381,7 @@ typedef struct _BAENGINE_SETUPDATE_ARGS | |||
381 | LPCWSTR wzDownloadSource; | 381 | LPCWSTR wzDownloadSource; |
382 | DWORD64 qwSize; | 382 | DWORD64 qwSize; |
383 | BOOTSTRAPPER_UPDATE_HASH_TYPE hashType; | 383 | BOOTSTRAPPER_UPDATE_HASH_TYPE hashType; |
384 | BYTE* rgbHash; | 384 | LPCWSTR wzHash; |
385 | DWORD cbHash; | ||
386 | } BAENGINE_SETUPDATE_ARGS; | 385 | } BAENGINE_SETUPDATE_ARGS; |
387 | 386 | ||
388 | typedef struct _BAENGINE_SETUPDATE_RESULTS | 387 | typedef struct _BAENGINE_SETUPDATE_RESULTS |
diff --git a/src/api/burn/WixToolset.Mba.Core/Engine.cs b/src/api/burn/WixToolset.Mba.Core/Engine.cs index 5ebada36..e7ab533b 100644 --- a/src/api/burn/WixToolset.Mba.Core/Engine.cs +++ b/src/api/burn/WixToolset.Mba.Core/Engine.cs | |||
@@ -240,9 +240,9 @@ namespace WixToolset.Mba.Core | |||
240 | } | 240 | } |
241 | 241 | ||
242 | /// <inheritdoc/> | 242 | /// <inheritdoc/> |
243 | public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, byte[] hash) | 243 | public void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash) |
244 | { | 244 | { |
245 | this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash, null == hash ? 0 : hash.Length); | 245 | this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash); |
246 | } | 246 | } |
247 | 247 | ||
248 | /// <inheritdoc/> | 248 | /// <inheritdoc/> |
diff --git a/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs b/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs index fdc9c3f6..408c9955 100644 --- a/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs +++ b/src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs | |||
@@ -123,21 +123,19 @@ namespace WixToolset.Mba.Core | |||
123 | ); | 123 | ); |
124 | 124 | ||
125 | /// <summary> | 125 | /// <summary> |
126 | /// See <see cref="IEngine.SetUpdate(string, string, long, UpdateHashType, byte[])"/>. | 126 | /// See <see cref="IEngine.SetUpdate(string, string, long, UpdateHashType, string)"/>. |
127 | /// </summary> | 127 | /// </summary> |
128 | /// <param name="wzLocalSource"></param> | 128 | /// <param name="wzLocalSource"></param> |
129 | /// <param name="wzDownloadSource"></param> | 129 | /// <param name="wzDownloadSource"></param> |
130 | /// <param name="qwValue"></param> | 130 | /// <param name="qwValue"></param> |
131 | /// <param name="hashType"></param> | 131 | /// <param name="hashType"></param> |
132 | /// <param name="rgbHash"></param> | 132 | /// <param name="wzHash"></param> |
133 | /// <param name="cbHash"></param> | ||
134 | void SetUpdate( | 133 | void SetUpdate( |
135 | [MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource, | 134 | [MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource, |
136 | [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource, | 135 | [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource, |
137 | [MarshalAs(UnmanagedType.U8)] long qwValue, | 136 | [MarshalAs(UnmanagedType.U8)] long qwValue, |
138 | [MarshalAs(UnmanagedType.U4)] UpdateHashType hashType, | 137 | [MarshalAs(UnmanagedType.U4)] UpdateHashType hashType, |
139 | [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=4)] byte[] rgbHash, | 138 | [MarshalAs(UnmanagedType.LPWStr)] string wzHash |
140 | [MarshalAs(UnmanagedType.U4)] int cbHash | ||
141 | ); | 139 | ); |
142 | 140 | ||
143 | /// <summary> | 141 | /// <summary> |
diff --git a/src/api/burn/WixToolset.Mba.Core/IEngine.cs b/src/api/burn/WixToolset.Mba.Core/IEngine.cs index 3e636961..2b9a90e0 100644 --- a/src/api/burn/WixToolset.Mba.Core/IEngine.cs +++ b/src/api/burn/WixToolset.Mba.Core/IEngine.cs | |||
@@ -142,7 +142,7 @@ namespace WixToolset.Mba.Core | |||
142 | /// <param name="size">Size of the expected update.</param> | 142 | /// <param name="size">Size of the expected update.</param> |
143 | /// <param name="hashType">Type of the hash expected on the update.</param> | 143 | /// <param name="hashType">Type of the hash expected on the update.</param> |
144 | /// <param name="hash">Optional hash expected for the update.</param> | 144 | /// <param name="hash">Optional hash expected for the update.</param> |
145 | void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, byte[] hash); | 145 | void SetUpdate(string localSource, string downloadSource, long size, UpdateHashType hashType, string hash); |
146 | 146 | ||
147 | /// <summary> | 147 | /// <summary> |
148 | /// Sets the URL to the update feed. | 148 | /// Sets the URL to the update feed. |
diff --git a/src/api/burn/balutil/BalBootstrapperEngine.cpp b/src/api/burn/balutil/BalBootstrapperEngine.cpp index 301b88a5..898a8a15 100644 --- a/src/api/burn/balutil/BalBootstrapperEngine.cpp +++ b/src/api/burn/balutil/BalBootstrapperEngine.cpp | |||
@@ -312,8 +312,7 @@ public: // IBootstrapperEngine | |||
312 | __in_z_opt LPCWSTR wzDownloadSource, | 312 | __in_z_opt LPCWSTR wzDownloadSource, |
313 | __in DWORD64 qwSize, | 313 | __in DWORD64 qwSize, |
314 | __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, | 314 | __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, |
315 | __in_bcount_opt(cbHash) BYTE* rgbHash, | 315 | __in_z_opt LPCWSTR wzHash |
316 | __in DWORD cbHash | ||
317 | ) | 316 | ) |
318 | { | 317 | { |
319 | BAENGINE_SETUPDATE_ARGS args = { }; | 318 | BAENGINE_SETUPDATE_ARGS args = { }; |
@@ -324,8 +323,7 @@ public: // IBootstrapperEngine | |||
324 | args.wzDownloadSource = wzDownloadSource; | 323 | args.wzDownloadSource = wzDownloadSource; |
325 | args.qwSize = qwSize; | 324 | args.qwSize = qwSize; |
326 | args.hashType = hashType; | 325 | args.hashType = hashType; |
327 | args.rgbHash = rgbHash; | 326 | args.wzHash = wzHash; |
328 | args.cbHash = cbHash; | ||
329 | 327 | ||
330 | results.cbSize = sizeof(results); | 328 | results.cbSize = sizeof(results); |
331 | 329 | ||
diff --git a/src/api/burn/balutil/inc/IBootstrapperEngine.h b/src/api/burn/balutil/inc/IBootstrapperEngine.h index ccb07f4f..2a108223 100644 --- a/src/api/burn/balutil/inc/IBootstrapperEngine.h +++ b/src/api/burn/balutil/inc/IBootstrapperEngine.h | |||
@@ -65,8 +65,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8 | |||
65 | __in_z_opt LPCWSTR wzDownloadSource, | 65 | __in_z_opt LPCWSTR wzDownloadSource, |
66 | __in DWORD64 qwSize, | 66 | __in DWORD64 qwSize, |
67 | __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, | 67 | __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType, |
68 | __in_bcount_opt(cbHash) BYTE* rgbHash, | 68 | __in_z_opt LPCWSTR wzHash |
69 | __in DWORD cbHash | ||
70 | ) = 0; | 69 | ) = 0; |
71 | 70 | ||
72 | STDMETHOD(SetLocalSource)( | 71 | STDMETHOD(SetLocalSource)( |
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 | ||
202 | LExit: | 202 | LExit: |
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 | ||
88 | HRESULT ExternalEngineSetLocalSource( | 87 | HRESULT 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 | } |