aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Kubiesa <alex.kubiesa@outlook.com>2021-02-15 20:08:21 +0000
committerRob Mensching <rob@firegiant.com>2021-02-15 16:39:59 -0800
commit0ce3a9b66da80c505fd8901df88d31b0ad43dac6 (patch)
tree8b35cbcbb5d5985d73fef64e7cb81994f3820d7f
parentc6e2213e818b869c44c1af7355fc06f45ebf1a1f (diff)
downloadwix-0ce3a9b66da80c505fd8901df88d31b0ad43dac6.tar.gz
wix-0ce3a9b66da80c505fd8901df88d31b0ad43dac6.tar.bz2
wix-0ce3a9b66da80c505fd8901df88d31b0ad43dac6.zip
Fix file size overflow error in ProcessPayloadsCommand.
Fixes #4008
-rw-r--r--src/WixToolset.Core.Burn/Bundles/ProcessPayloadsCommand.cs2
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs52
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/Bundle.en-us.wxl10
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/Bundle.wxs13
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/MsiPackage/Shared.dll1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/MsiPackage/test.txt1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/fakeba.dll1
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/large_file.dat2
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/test.msibin0 -> 32768 bytes
9 files changed, 81 insertions, 1 deletions
diff --git a/src/WixToolset.Core.Burn/Bundles/ProcessPayloadsCommand.cs b/src/WixToolset.Core.Burn/Bundles/ProcessPayloadsCommand.cs
index 8811c301..db5b03fb 100644
--- a/src/WixToolset.Core.Burn/Bundles/ProcessPayloadsCommand.cs
+++ b/src/WixToolset.Core.Burn/Bundles/ProcessPayloadsCommand.cs
@@ -117,7 +117,7 @@ namespace WixToolset.Core.Burn.Bundles
117 117
118 if (null != fileInfo) 118 if (null != fileInfo)
119 { 119 {
120 payload.FileSize = (int)fileInfo.Length; 120 payload.FileSize = fileInfo.Length;
121 121
122 payload.Hash = BundleHashAlgorithm.Hash(fileInfo); 122 payload.Hash = BundleHashAlgorithm.Hash(fileInfo);
123 } 123 }
diff --git a/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs b/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
index 094e4df2..0660dd7b 100644
--- a/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
+++ b/src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
@@ -366,5 +366,57 @@ namespace WixToolsetTest.CoreIntegration
366 Assert.InRange(result.ExitCode, 2, Int32.MaxValue); 366 Assert.InRange(result.ExitCode, 2, Int32.MaxValue);
367 } 367 }
368 } 368 }
369
370 [Fact]
371 public void CanBuildBundleWithLargePayload()
372 {
373 var folder = TestData.Get(@"TestData\LargePayload");
374
375 // Overwrite the payload with a 2.5 GiB file. We do this dynamically to avoid committing such
376 // a large file to source control.
377 var largeFile = Path.Combine(folder, "data", "large_file.dat");
378 const long TwoAndAHalfGigabytes = 2_684_354_560;
379 using (var stream = File.Create(largeFile))
380 {
381 stream.Seek(TwoAndAHalfGigabytes - 1, SeekOrigin.Begin);
382 stream.WriteByte(1);
383 }
384
385 using (var fs = new DisposableFileSystem())
386 {
387 var baseFolder = fs.GetFolder();
388 var intermediateFolder = Path.Combine(baseFolder, "obj");
389 var exePath = Path.Combine(baseFolder, @"bin\test.exe");
390 var pdbPath = Path.Combine(baseFolder, @"bin\test.wixpdb");
391
392 var result = WixRunner.Execute(new[]
393 {
394 "build",
395 Path.Combine(folder, "Bundle.wxs"),
396 "-loc", Path.Combine(folder, "Bundle.en-us.wxl"),
397 "-bindpath", Path.Combine(folder, "data"),
398 "-intermediateFolder", intermediateFolder,
399 "-o", exePath,
400 });
401
402 result.AssertSuccess();
403 Assert.Empty(result.Messages.Where(m => m.Level == MessageLevel.Warning));
404
405 Assert.True(File.Exists(exePath));
406 Assert.True(File.Exists(pdbPath));
407 Assert.True(File.Exists(Path.Combine(baseFolder, @"bin\large_file.dat")));
408
409 using (var wixOutput = WixOutput.Read(pdbPath))
410 {
411 var intermediate = Intermediate.Load(wixOutput);
412 var section = intermediate.Sections.Single();
413
414 var payloadSymbol = section.Symbols.OfType<WixBundlePayloadSymbol>().Where(x => x.Name == "large_file.dat").Single();
415 Assert.Equal(TwoAndAHalfGigabytes, payloadSymbol.FileSize);
416 }
417 }
418
419 File.Delete(largeFile);
420 }
369 } 421 }
370} 422}
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/Bundle.en-us.wxl b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/Bundle.en-us.wxl
new file mode 100644
index 00000000..bc1dee83
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/Bundle.en-us.wxl
@@ -0,0 +1,10 @@
1<?xml version="1.0" encoding="utf-8"?>
2
3<!--
4This file contains the declaration of all the localizable strings.
5-->
6<WixLocalization xmlns="http://wixtoolset.org/schemas/v4/wxl" Culture="en-US">
7
8 <String Id="BundleName">~TestBundle</String>
9
10</WixLocalization>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/Bundle.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/Bundle.wxs
new file mode 100644
index 00000000..5c7735b5
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/Bundle.wxs
@@ -0,0 +1,13 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 <Bundle Name="!(loc.BundleName)" Version="!(bind.packageVersion.test.msi)" Manufacturer="Example Corporation" UpgradeCode="047730a5-30fe-4a62-a520-da9381b8226a">
3 <BootstrapperApplication>
4 <BootstrapperApplicationDll SourceFile="fakeba.dll" />
5 </BootstrapperApplication>
6 <Chain>
7 <MsiPackage SourceFile="test.msi">
8 <MsiProperty Name="TEST" Value="1" />
9 <Payload Compressed="no" SourceFile="large_file.dat" />
10 </MsiPackage>
11 </Chain>
12 </Bundle>
13</Wix>
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/MsiPackage/Shared.dll b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/MsiPackage/Shared.dll
new file mode 100644
index 00000000..0e461ba8
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/MsiPackage/Shared.dll
@@ -0,0 +1 @@
This is Shared.dll. \ No newline at end of file
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/MsiPackage/test.txt b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/MsiPackage/test.txt
new file mode 100644
index 00000000..8b986220
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/MsiPackage/test.txt
@@ -0,0 +1 @@
This is test.txt \ No newline at end of file
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/fakeba.dll b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/fakeba.dll
new file mode 100644
index 00000000..970efdf0
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/fakeba.dll
@@ -0,0 +1 @@
This is a fakeba.dll \ No newline at end of file
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/large_file.dat b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/large_file.dat
new file mode 100644
index 00000000..8115cc60
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/large_file.dat
@@ -0,0 +1,2 @@
1When running the tests, this file will be overwritten with 2.5GB of data to test how Wix handles large files. We've avoided
2committing such a large file to Git as it would bloat the repo.
diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/test.msi b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/test.msi
new file mode 100644
index 00000000..0722d60e
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/test.msi
Binary files differ