@joebigelow / wix-1 / commits / 6a45cb76

Update hashes are now hex strings.

Fixes https://github.com/wixtoolset/issues/issues/6901.

Bob Arnson committed Sep 9, 2022 at 21:21 UTC 6a45cb7687de57056532fe897a708435deec2ea3
11 files changed +30 -33
src/api/burn/WixToolset.BootstrapperCore.Native/inc/BootstrapperEngine.h
+1 -2
@@ -381,8 +381,7 @@ typedef struct _BAENGINE_SETUPDATE_ARGS
381 LPCWSTR wzDownloadSource;
382 DWORD64 qwSize;
383 BOOTSTRAPPER_UPDATE_HASH_TYPE hashType;
384 - BYTE* rgbHash;
385 - DWORD cbHash;
384 + LPCWSTR wzHash;
385 } BAENGINE_SETUPDATE_ARGS;
386
387 typedef struct _BAENGINE_SETUPDATE_RESULTS
src/api/burn/WixToolset.Mba.Core/Engine.cs
+2 -2
@@ -240,9 +240,9 @@ namespace WixToolset.Mba.Core
240 }
241
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 {
245 - this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash, null == hash ? 0 : hash.Length);
245 + this.engine.SetUpdate(localSource, downloadSource, size, hashType, hash);
246 }
247
248 /// <inheritdoc/>
src/api/burn/WixToolset.Mba.Core/IBootstrapperEngine.cs
+3 -5
@@ -123,21 +123,19 @@ namespace WixToolset.Mba.Core
123 );
124
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>
128 /// <param name="wzLocalSource"></param>
129 /// <param name="wzDownloadSource"></param>
130 /// <param name="qwValue"></param>
131 /// <param name="hashType"></param>
132 - /// <param name="rgbHash"></param>
133 - /// <param name="cbHash"></param>
132 + /// <param name="wzHash"></param>
133 void SetUpdate(
134 [MarshalAs(UnmanagedType.LPWStr)] string wzLocalSource,
135 [MarshalAs(UnmanagedType.LPWStr)] string wzDownloadSource,
136 [MarshalAs(UnmanagedType.U8)] long qwValue,
137 [MarshalAs(UnmanagedType.U4)] UpdateHashType hashType,
139 - [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=4)] byte[] rgbHash,
140 - [MarshalAs(UnmanagedType.U4)] int cbHash
138 + [MarshalAs(UnmanagedType.LPWStr)] string wzHash
139 );
140
141 /// <summary>
src/api/burn/WixToolset.Mba.Core/IEngine.cs
+1 -1
@@ -142,7 +142,7 @@ namespace WixToolset.Mba.Core
142 /// <param name="size">Size of the expected 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>
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
147 /// <summary>
148 /// Sets the URL to the update feed.
src/api/burn/balutil/BalBootstrapperEngine.cpp
+2 -4
@@ -312,8 +312,7 @@ public: // IBootstrapperEngine
312 __in_z_opt LPCWSTR wzDownloadSource,
313 __in DWORD64 qwSize,
314 __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType,
315 - __in_bcount_opt(cbHash) BYTE* rgbHash,
316 - __in DWORD cbHash
315 + __in_z_opt LPCWSTR wzHash
316 )
317 {
318 BAENGINE_SETUPDATE_ARGS args = { };
@@ -324,8 +323,7 @@ public: // IBootstrapperEngine
323 args.wzDownloadSource = wzDownloadSource;
324 args.qwSize = qwSize;
325 args.hashType = hashType;
327 - args.rgbHash = rgbHash;
328 - args.cbHash = cbHash;
326 + args.wzHash = wzHash;
327
328 results.cbSize = sizeof(results);
329
src/api/burn/balutil/inc/IBootstrapperEngine.h
+1 -2
@@ -65,8 +65,7 @@ DECLARE_INTERFACE_IID_(IBootstrapperEngine, IUnknown, "6480D616-27A0-44D7-905B-8
65 __in_z_opt LPCWSTR wzDownloadSource,
66 __in DWORD64 qwSize,
67 __in BOOTSTRAPPER_UPDATE_HASH_TYPE hashType,
68 - __in_bcount_opt(cbHash) BYTE* rgbHash,
69 - __in DWORD cbHash
68 + __in_z_opt LPCWSTR wzHash
69 ) = 0;
70
71 STDMETHOD(SetLocalSource)(
src/burn/engine/EngineForApplication.cpp
+1 -1
@@ -197,7 +197,7 @@ static HRESULT BAEngineSetUpdate(
197 ValidateMessageArgs(hr, pvArgs, BAENGINE_SETUPDATE_ARGS, pArgs);
198 ValidateMessageResults(hr, pvResults, BAENGINE_SETUPDATE_RESULTS, pResults);
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
202 LExit:
203 return hr;
src/burn/engine/externalengine.cpp
+4 -5
@@ -269,8 +269,7 @@ HRESULT ExternalEngineSetUpdate(
269 __in_z_opt LPCWSTR wzDownloadSource,
270 __in const DWORD64 qwSize,
271 __in const BOOTSTRAPPER_UPDATE_HASH_TYPE hashType,
272 - __in_opt const BYTE* rgbHash,
273 - __in const DWORD cbHash
272 + __in_opt LPCWSTR wzHash
273 )
274 {
275 HRESULT hr = S_OK;
@@ -293,11 +292,11 @@ HRESULT ExternalEngineSetUpdate(
292
293 if (!fRemove)
294 {
296 - if (BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE == hashType && (0 != cbHash || rgbHash))
295 + if (BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE == hashType && wzHash && *wzHash)
296 {
297 ExitFunction1(hr = E_INVALIDARG);
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)))
300 {
301 ExitFunction1(hr = E_INVALIDARG);
302 }
@@ -335,7 +334,7 @@ HRESULT ExternalEngineSetUpdate(
334 wzLocalSource = sczFilePath;
335 }
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);
338 ExitOnFailure(hr, "Failed to set update bundle.");
339
340 pEngineState->update.fUpdateAvailable = TRUE;
src/burn/engine/externalengine.h
+2 -3
@@ -81,9 +81,8 @@ HRESULT ExternalEngineSetUpdate(
81 __in_z_opt LPCWSTR wzDownloadSource,
82 __in const DWORD64 qwSize,
83 __in const BOOTSTRAPPER_UPDATE_HASH_TYPE hashType,
84 - __in_opt const BYTE* rgbHash,
85 - __in const DWORD cbHash
86 - );
84 + __in_opt LPCWSTR wzHash
85 +);
86
87 HRESULT ExternalEngineSetLocalSource(
88 __in BURN_ENGINE_STATE* pEngineState,
src/burn/engine/pseudobundle.cpp
+11 -5
@@ -142,9 +142,8 @@ extern "C" HRESULT PseudoBundleInitializeUpdateBundle(
142 __in_z_opt LPCWSTR wzDownloadSource,
143 __in DWORD64 qwSize,
144 __in_z LPCWSTR wzInstallArguments,
145 - __in_opt const BYTE* pbHash,
146 - __in const DWORD cbHash
147 - )
145 + __in_opt LPCWSTR wzHash
146 +)
147 {
148 HRESULT hr = S_OK;
149 BURN_PAYLOAD* pPayload = NULL;
@@ -176,13 +175,20 @@ extern "C" HRESULT PseudoBundleInitializeUpdateBundle(
175 ExitOnFailure(hr, "Failed to copy download source for pseudo bundle.");
176 }
177
179 - if (pbHash)
178 + if (wzHash && *wzHash)
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 +
186 pPayload->pbHash = static_cast<BYTE*>(MemAlloc(cbHash, FALSE));
187 ExitOnNull(pPayload->pbHash, hr, E_OUTOFMEMORY, "Failed to allocate memory for update bundle payload hash.");
188
189 pPayload->cbHash = cbHash;
185 - memcpy_s(pPayload->pbHash, pPayload->cbHash, pbHash, cbHash);
190 +
191 + memcpy_s(pPayload->pbHash, pPayload->cbHash, rgbHash, cbHash);
192 }
193
194 pPackage->type = BURN_PACKAGE_TYPE_EXE;
src/burn/engine/pseudobundle.h
+2 -3
@@ -34,9 +34,8 @@ HRESULT PseudoBundleInitializeUpdateBundle(
34 __in_z_opt LPCWSTR wzDownloadSource,
35 __in DWORD64 qwSize,
36 __in_z LPCWSTR wzInstallArguments,
37 - __in_opt const BYTE* pbHash,
38 - __in const DWORD cbHash
39 - );
37 + __in_opt LPCWSTR wzHash
38 +);
39
40 #if defined(__cplusplus)
41 }