@joebigelow / wix-1 / commits / ba93485c

Report E_MOREDATA from Bal functions when string buffer too small

WiX v4 (and probably v3) standardized on the error code E_MOREDATA when string buffers were too small instead of E_INSUFFICIIENT_BUFFER. This fixes v5 to match in a few missing cases. Fixes 8094

Rob Mensching committed Apr 4, 2024 at 15:41 UTC ba93485c940b0bae6e0b6a005fdd1819652f3984
4 files changed +73
src/api/burn/balutil/BalBootstrapperEngine.cpp
+20
@@ -216,6 +216,10 @@ public: // IBootstrapperEngine
216 if (wzValue)
217 {
218 hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue);
219 + if (E_INSUFFICIENT_BUFFER == hr)
220 + {
221 + hr = E_MOREDATA;
222 + }
223 }
224 else if (results.cchValue)
225 {
@@ -292,6 +296,10 @@ public: // IBootstrapperEngine
296 if (wzValue)
297 {
298 hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue);
299 + if (E_INSUFFICIENT_BUFFER == hr)
300 + {
301 + hr = E_MOREDATA;
302 + }
303 }
304 else if (results.cchValue)
305 {
@@ -373,6 +381,10 @@ public: // IBootstrapperEngine
381 if (wzValue)
382 {
383 hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue);
384 + if (E_INSUFFICIENT_BUFFER == hr)
385 + {
386 + hr = E_MOREDATA;
387 + }
388 }
389 else if (results.cchValue)
390 {
@@ -449,6 +461,10 @@ public: // IBootstrapperEngine
461 if (wzOut)
462 {
463 hr = ::StringCchCopyW(wzOut, *pcchOut, results.wzOut);
464 + if (E_INSUFFICIENT_BUFFER == hr)
465 + {
466 + hr = E_MOREDATA;
467 + }
468 }
469 else if (results.cchOut)
470 {
@@ -525,6 +541,10 @@ public: // IBootstrapperEngine
541 if (wzOut)
542 {
543 hr = ::StringCchCopyW(wzOut, *pcchOut, results.wzOut);
544 + if (E_INSUFFICIENT_BUFFER == hr)
545 + {
546 + hr = E_MOREDATA;
547 + }
548 }
549 else if (results.cchOut)
550 {
src/test/burn/TestData/WixStdBaTests/BalCondition/BalCondition.wixproj new
+18
@@ -0,0 +1,18 @@
1 +<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
2 +
3 +<Project Sdk="WixToolset.Sdk">
4 + <PropertyGroup>
5 + <OutputType>Bundle</OutputType>
6 + <BA>hyperlinkLicense</BA>
7 + <UpgradeCode>{42CCE8AB-777A-481F-9EA2-0B5B10179E8A}</UpgradeCode>
8 + <DefineConstants>$(DefineConstants);Version=1.0</DefineConstants>
9 + </PropertyGroup>
10 +
11 + <ItemGroup>
12 + <ProjectReference Include="..\PackageA\PackageA.wixproj" />
13 + </ItemGroup>
14 +
15 + <ItemGroup>
16 + <PackageReference Include="WixToolset.BootstrapperApplications.wixext" />
17 + </ItemGroup>
18 +</Project>
src/test/burn/TestData/WixStdBaTests/BalCondition/BalCondition.wxs new
+18
@@ -0,0 +1,18 @@
1 +<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
2 +
3 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
4 + <Bundle Name="~$(var.TestGroupName) - $(var.BundleName)" Version="$(var.Version)" UpgradeCode="$(var.UpgradeCode)" Compressed="yes">
5 + <Log Prefix="~$(var.TestGroupName)_$(var.BundleName)" />
6 +
7 + <BootstrapperApplication>
8 + <bal:WixStandardBootstrapperApplication LicenseUrl="" Theme="hyperlinkLargeLicense" SuppressOptionsUI="yes" SuppressDowngradeFailure="yes" />
9 + </BootstrapperApplication>
10 +
11 + <bal:Condition Condition="1" Message="This is a first condition that we need to meet" />
12 + <bal:Condition Condition="1" Message="This is a second condition that we need to meet with a longer message" />
13 +
14 + <Chain>
15 + <MsiPackage Id="PackageA" SourceFile="$(var.PackageA.TargetPath)" />
16 + </Chain>
17 + </Bundle>
18 +</Wix>
src/test/burn/WixToolsetTest.BurnE2E/WixStdBaTests.cs
+17
@@ -9,6 +9,23 @@ namespace WixToolsetTest.BurnE2E
9 {
10 public WixStdBaTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }
11
12 + [RuntimeFact]
13 + public void SucceedsWithMultipleConditions()
14 + {
15 + var packageA = this.CreatePackageInstaller("PackageA");
16 + var bundle = this.CreateBundleInstaller("BalCondition");
17 +
18 + packageA.VerifyInstalled(false);
19 +
20 + bundle.Install();
21 + bundle.VerifyRegisteredAndInPackageCache();
22 + packageA.VerifyInstalled(true);
23 +
24 + bundle.Uninstall();
25 + bundle.VerifyUnregisteredAndRemovedFromPackageCache();
26 + packageA.VerifyInstalled(false);
27 + }
28 +
29 [RuntimeFact]
30 public void ExitsWithErrorWhenDowngradingWithoutSuppression()
31 {