aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2024-04-04 15:41:57 -0700
committerRob Mensching <rob@firegiant.com>2024-04-04 16:33:49 -0700
commitba93485c940b0bae6e0b6a005fdd1819652f3984 (patch)
treef887f83dc535fc108e399e0f2a886beb71945bde
parentf9ae2561ac4a39ba810234db3b562ca2898ccaf4 (diff)
downloadwix-ba93485c940b0bae6e0b6a005fdd1819652f3984.tar.gz
wix-ba93485c940b0bae6e0b6a005fdd1819652f3984.tar.bz2
wix-ba93485c940b0bae6e0b6a005fdd1819652f3984.zip
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
-rw-r--r--src/api/burn/balutil/BalBootstrapperEngine.cpp20
-rw-r--r--src/test/burn/TestData/WixStdBaTests/BalCondition/BalCondition.wixproj18
-rw-r--r--src/test/burn/TestData/WixStdBaTests/BalCondition/BalCondition.wxs18
-rw-r--r--src/test/burn/WixToolsetTest.BurnE2E/WixStdBaTests.cs17
4 files changed, 73 insertions, 0 deletions
diff --git a/src/api/burn/balutil/BalBootstrapperEngine.cpp b/src/api/burn/balutil/BalBootstrapperEngine.cpp
index b924906e..28608cb9 100644
--- a/src/api/burn/balutil/BalBootstrapperEngine.cpp
+++ b/src/api/burn/balutil/BalBootstrapperEngine.cpp
@@ -216,6 +216,10 @@ public: // IBootstrapperEngine
216 if (wzValue) 216 if (wzValue)
217 { 217 {
218 hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue); 218 hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue);
219 if (E_INSUFFICIENT_BUFFER == hr)
220 {
221 hr = E_MOREDATA;
222 }
219 } 223 }
220 else if (results.cchValue) 224 else if (results.cchValue)
221 { 225 {
@@ -292,6 +296,10 @@ public: // IBootstrapperEngine
292 if (wzValue) 296 if (wzValue)
293 { 297 {
294 hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue); 298 hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue);
299 if (E_INSUFFICIENT_BUFFER == hr)
300 {
301 hr = E_MOREDATA;
302 }
295 } 303 }
296 else if (results.cchValue) 304 else if (results.cchValue)
297 { 305 {
@@ -373,6 +381,10 @@ public: // IBootstrapperEngine
373 if (wzValue) 381 if (wzValue)
374 { 382 {
375 hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue); 383 hr = ::StringCchCopyW(wzValue, *pcchValue, results.wzValue);
384 if (E_INSUFFICIENT_BUFFER == hr)
385 {
386 hr = E_MOREDATA;
387 }
376 } 388 }
377 else if (results.cchValue) 389 else if (results.cchValue)
378 { 390 {
@@ -449,6 +461,10 @@ public: // IBootstrapperEngine
449 if (wzOut) 461 if (wzOut)
450 { 462 {
451 hr = ::StringCchCopyW(wzOut, *pcchOut, results.wzOut); 463 hr = ::StringCchCopyW(wzOut, *pcchOut, results.wzOut);
464 if (E_INSUFFICIENT_BUFFER == hr)
465 {
466 hr = E_MOREDATA;
467 }
452 } 468 }
453 else if (results.cchOut) 469 else if (results.cchOut)
454 { 470 {
@@ -525,6 +541,10 @@ public: // IBootstrapperEngine
525 if (wzOut) 541 if (wzOut)
526 { 542 {
527 hr = ::StringCchCopyW(wzOut, *pcchOut, results.wzOut); 543 hr = ::StringCchCopyW(wzOut, *pcchOut, results.wzOut);
544 if (E_INSUFFICIENT_BUFFER == hr)
545 {
546 hr = E_MOREDATA;
547 }
528 } 548 }
529 else if (results.cchOut) 549 else if (results.cchOut)
530 { 550 {
diff --git a/src/test/burn/TestData/WixStdBaTests/BalCondition/BalCondition.wixproj b/src/test/burn/TestData/WixStdBaTests/BalCondition/BalCondition.wixproj
new file mode 100644
index 00000000..7e0224e2
--- /dev/null
+++ b/src/test/burn/TestData/WixStdBaTests/BalCondition/BalCondition.wixproj
@@ -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>
diff --git a/src/test/burn/TestData/WixStdBaTests/BalCondition/BalCondition.wxs b/src/test/burn/TestData/WixStdBaTests/BalCondition/BalCondition.wxs
new file mode 100644
index 00000000..e3c36df7
--- /dev/null
+++ b/src/test/burn/TestData/WixStdBaTests/BalCondition/BalCondition.wxs
@@ -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>
diff --git a/src/test/burn/WixToolsetTest.BurnE2E/WixStdBaTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/WixStdBaTests.cs
index ec7bca6f..45a122a4 100644
--- a/src/test/burn/WixToolsetTest.BurnE2E/WixStdBaTests.cs
+++ b/src/test/burn/WixToolsetTest.BurnE2E/WixStdBaTests.cs
@@ -10,6 +10,23 @@ namespace WixToolsetTest.BurnE2E
10 public WixStdBaTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } 10 public WixStdBaTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }
11 11
12 [RuntimeFact] 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]
13 public void ExitsWithErrorWhenDowngradingWithoutSuppression() 30 public void ExitsWithErrorWhenDowngradingWithoutSuppression()
14 { 31 {
15 var packageA = this.CreatePackageInstaller("PackageA"); 32 var packageA = this.CreatePackageInstaller("PackageA");