Fix file size overflow error in ProcessPayloadsCommand.
Fixes #4008
Alex Kubiesa committed
Feb 15, 2021 at 20:08 UTC
0ce3a9b66da80c505fd8901df88d31b0ad43dac6
9 files changed
+81
-1
src/WixToolset.Core.Burn/Bundles/ProcessPayloadsCommand.cs
+1
-1
@@ -117,7 +117,7 @@ namespace WixToolset.Core.Burn.Bundles
117
118
if (null != fileInfo)
119
{
120
- payload.FileSize = (int)fileInfo.Length;
120
+ payload.FileSize = fileInfo.Length;
121
122
payload.Hash = BundleHashAlgorithm.Hash(fileInfo);
123
}
src/test/WixToolsetTest.CoreIntegration/BundleFixture.cs
+52
@@ -366,5 +366,57 @@ namespace WixToolsetTest.CoreIntegration
366
Assert.InRange(result.ExitCode, 2, Int32.MaxValue);
367
}
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
+ }
421
}
422
}
src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/Bundle.en-us.wxl
new
+10
@@ -0,0 +1,10 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+
3
+<!--
4
+This 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>
src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/Bundle.wxs
new
+13
@@ -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>
src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/MsiPackage/Shared.dll
new
+1
@@ -0,0 +1 @@
1
+This is Shared.dll.
\ No newline at end of file
src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/MsiPackage/test.txt
new
+1
@@ -0,0 +1 @@
1
+This is test.txt
\ No newline at end of file
src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/fakeba.dll
new
+1
@@ -0,0 +1 @@
1
+This is a fakeba.dll
\ No newline at end of file
src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/large_file.dat
new
+2
@@ -0,0 +1,2 @@
1
+When running the tests, this file will be overwritten with 2.5GB of data to test how Wix handles large files. We've avoided
2
+committing such a large file to Git as it would bloat the repo.
src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/test.msi
Binary files /dev/null and b/src/test/WixToolsetTest.CoreIntegration/TestData/LargePayload/data/test.msi differ