diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2020-12-14 14:30:27 -0600 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2020-12-14 14:54:27 -0600 |
| commit | 155a2a61ee57eee7735d031c489c90255b39797b (patch) | |
| tree | 55e7d2530d9430ccda7837bbbf4be6c23dbfbb4f | |
| parent | f970f584c1caac8927ee9d9090fe19f5a2a8b50d (diff) | |
| download | wix-155a2a61ee57eee7735d031c489c90255b39797b.tar.gz wix-155a2a61ee57eee7735d031c489c90255b39797b.tar.bz2 wix-155a2a61ee57eee7735d031c489c90255b39797b.zip | |
WIXBUG:6299 - Fix OverflowException in ReadUInt32.
| -rw-r--r-- | WixToolset.Core.sln | 15 | ||||
| -rw-r--r-- | appveyor.cmd | 1 | ||||
| -rw-r--r-- | src/WixToolset.Core.Burn/Bundles/BurnCommon.cs | 10 | ||||
| -rw-r--r-- | src/WixToolset.Core.Burn/WixToolset.Core.Burn.csproj | 3 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.Core.Burn/BurnReaderFixture.cs | 44 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.Core.Burn/WixToolsetTest.Core.Burn.csproj | 28 |
6 files changed, 96 insertions, 5 deletions
diff --git a/WixToolset.Core.sln b/WixToolset.Core.sln index 6c804904..a97f38d9 100644 --- a/WixToolset.Core.sln +++ b/WixToolset.Core.sln | |||
| @@ -14,6 +14,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example.Extension", "src\te | |||
| 14 | EndProject | 14 | EndProject |
| 15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.CoreIntegration", "src\test\WixToolsetTest.CoreIntegration\WixToolsetTest.CoreIntegration.csproj", "{E8A08E86-1780-4ED4-8F63-AB2B52C1C16B}" | 15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.CoreIntegration", "src\test\WixToolsetTest.CoreIntegration\WixToolsetTest.CoreIntegration.csproj", "{E8A08E86-1780-4ED4-8F63-AB2B52C1C16B}" |
| 16 | EndProject | 16 | EndProject |
| 17 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Core.Burn", "src\test\WixToolsetTest.Core.Burn\WixToolsetTest.Core.Burn.csproj", "{DF63F589-028E-45A1-A212-948FACF1FDCD}" | ||
| 18 | EndProject | ||
| 17 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Core.TestPackage", "src\WixToolset.Core.TestPackage\WixToolset.Core.TestPackage.csproj", "{853716DB-C02C-41BD-91BC-79CDC0C17D10}" | 19 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Core.TestPackage", "src\WixToolset.Core.TestPackage\WixToolset.Core.TestPackage.csproj", "{853716DB-C02C-41BD-91BC-79CDC0C17D10}" |
| 18 | EndProject | 20 | EndProject |
| 19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompileCoreTestExtensionWixlib", "src\test\CompileCoreTestExtensionWixlib\CompileCoreTestExtensionWixlib.csproj", "{23FC60D7-B101-42F8-9786-DB7A9CD964A2}" | 21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompileCoreTestExtensionWixlib", "src\test\CompileCoreTestExtensionWixlib\CompileCoreTestExtensionWixlib.csproj", "{23FC60D7-B101-42F8-9786-DB7A9CD964A2}" |
| @@ -88,6 +90,18 @@ Global | |||
| 88 | {E8A08E86-1780-4ED4-8F63-AB2B52C1C16B}.Release|x64.Build.0 = Release|Any CPU | 90 | {E8A08E86-1780-4ED4-8F63-AB2B52C1C16B}.Release|x64.Build.0 = Release|Any CPU |
| 89 | {E8A08E86-1780-4ED4-8F63-AB2B52C1C16B}.Release|x86.ActiveCfg = Release|Any CPU | 91 | {E8A08E86-1780-4ED4-8F63-AB2B52C1C16B}.Release|x86.ActiveCfg = Release|Any CPU |
| 90 | {E8A08E86-1780-4ED4-8F63-AB2B52C1C16B}.Release|x86.Build.0 = Release|Any CPU | 92 | {E8A08E86-1780-4ED4-8F63-AB2B52C1C16B}.Release|x86.Build.0 = Release|Any CPU |
| 93 | {DF63F589-028E-45A1-A212-948FACF1FDCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| 94 | {DF63F589-028E-45A1-A212-948FACF1FDCD}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| 95 | {DF63F589-028E-45A1-A212-948FACF1FDCD}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
| 96 | {DF63F589-028E-45A1-A212-948FACF1FDCD}.Debug|x64.Build.0 = Debug|Any CPU | ||
| 97 | {DF63F589-028E-45A1-A212-948FACF1FDCD}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
| 98 | {DF63F589-028E-45A1-A212-948FACF1FDCD}.Debug|x86.Build.0 = Debug|Any CPU | ||
| 99 | {DF63F589-028E-45A1-A212-948FACF1FDCD}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| 100 | {DF63F589-028E-45A1-A212-948FACF1FDCD}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| 101 | {DF63F589-028E-45A1-A212-948FACF1FDCD}.Release|x64.ActiveCfg = Release|Any CPU | ||
| 102 | {DF63F589-028E-45A1-A212-948FACF1FDCD}.Release|x64.Build.0 = Release|Any CPU | ||
| 103 | {DF63F589-028E-45A1-A212-948FACF1FDCD}.Release|x86.ActiveCfg = Release|Any CPU | ||
| 104 | {DF63F589-028E-45A1-A212-948FACF1FDCD}.Release|x86.Build.0 = Release|Any CPU | ||
| 91 | {853716DB-C02C-41BD-91BC-79CDC0C17D10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | 105 | {853716DB-C02C-41BD-91BC-79CDC0C17D10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| 92 | {853716DB-C02C-41BD-91BC-79CDC0C17D10}.Debug|Any CPU.Build.0 = Debug|Any CPU | 106 | {853716DB-C02C-41BD-91BC-79CDC0C17D10}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| 93 | {853716DB-C02C-41BD-91BC-79CDC0C17D10}.Debug|x64.ActiveCfg = Debug|Any CPU | 107 | {853716DB-C02C-41BD-91BC-79CDC0C17D10}.Debug|x64.ActiveCfg = Debug|Any CPU |
| @@ -119,6 +133,7 @@ Global | |||
| 119 | GlobalSection(NestedProjects) = preSolution | 133 | GlobalSection(NestedProjects) = preSolution |
| 120 | {C66C2503-C671-4230-8B48-1D93A8532A28} = {1284331E-BC6C-426D-AAAF-140C0174F875} | 134 | {C66C2503-C671-4230-8B48-1D93A8532A28} = {1284331E-BC6C-426D-AAAF-140C0174F875} |
| 121 | {E8A08E86-1780-4ED4-8F63-AB2B52C1C16B} = {1284331E-BC6C-426D-AAAF-140C0174F875} | 135 | {E8A08E86-1780-4ED4-8F63-AB2B52C1C16B} = {1284331E-BC6C-426D-AAAF-140C0174F875} |
| 136 | {DF63F589-028E-45A1-A212-948FACF1FDCD} = {1284331E-BC6C-426D-AAAF-140C0174F875} | ||
| 122 | {23FC60D7-B101-42F8-9786-DB7A9CD964A2} = {1284331E-BC6C-426D-AAAF-140C0174F875} | 137 | {23FC60D7-B101-42F8-9786-DB7A9CD964A2} = {1284331E-BC6C-426D-AAAF-140C0174F875} |
| 123 | EndGlobalSection | 138 | EndGlobalSection |
| 124 | GlobalSection(ExtensibilityGlobals) = postSolution | 139 | GlobalSection(ExtensibilityGlobals) = postSolution |
diff --git a/appveyor.cmd b/appveyor.cmd index 9cfe85a6..e5cc4731 100644 --- a/appveyor.cmd +++ b/appveyor.cmd | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | @set _P=%~dp0build\Release\publish | 3 | @set _P=%~dp0build\Release\publish |
| 4 | 4 | ||
| 5 | dotnet test -c Release src\test\WixToolsetTest.CoreIntegration || exit /b | 5 | dotnet test -c Release src\test\WixToolsetTest.CoreIntegration || exit /b |
| 6 | dotnet test -c Release src\test\WixToolsetTest.Core.Burn || exit /b | ||
| 6 | 7 | ||
| 7 | dotnet pack -c Release src\WixToolset.Core || exit /b | 8 | dotnet pack -c Release src\WixToolset.Core || exit /b |
| 8 | dotnet pack -c Release src\WixToolset.Core.Burn || exit /b | 9 | dotnet pack -c Release src\WixToolset.Core.Burn || exit /b |
diff --git a/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs b/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs index 5cff0b5a..01c9f9ca 100644 --- a/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs +++ b/src/WixToolset.Core.Burn/Bundles/BurnCommon.cs | |||
| @@ -354,7 +354,7 @@ namespace WixToolset.Core.Burn.Bundles | |||
| 354 | /// <param name="bytes">Array from which to read.</param> | 354 | /// <param name="bytes">Array from which to read.</param> |
| 355 | /// <param name="offset">Beginning offset from which to read.</param> | 355 | /// <param name="offset">Beginning offset from which to read.</param> |
| 356 | /// <returns>value at offset</returns> | 356 | /// <returns>value at offset</returns> |
| 357 | private static UInt16 ReadUInt16(byte[] bytes, UInt32 offset) | 357 | internal static UInt16 ReadUInt16(byte[] bytes, UInt32 offset) |
| 358 | { | 358 | { |
| 359 | Debug.Assert(offset + 2 <= bytes.Length); | 359 | Debug.Assert(offset + 2 <= bytes.Length); |
| 360 | return (UInt16)(bytes[offset] + (bytes[offset + 1] << 8)); | 360 | return (UInt16)(bytes[offset] + (bytes[offset + 1] << 8)); |
| @@ -366,10 +366,10 @@ namespace WixToolset.Core.Burn.Bundles | |||
| 366 | /// <param name="bytes">Array from which to read.</param> | 366 | /// <param name="bytes">Array from which to read.</param> |
| 367 | /// <param name="offset">Beginning offset from which to read.</param> | 367 | /// <param name="offset">Beginning offset from which to read.</param> |
| 368 | /// <returns>value at offset</returns> | 368 | /// <returns>value at offset</returns> |
| 369 | private static UInt32 ReadUInt32(byte[] bytes, UInt32 offset) | 369 | internal static UInt32 ReadUInt32(byte[] bytes, UInt32 offset) |
| 370 | { | 370 | { |
| 371 | Debug.Assert(offset + 4 <= bytes.Length); | 371 | Debug.Assert(offset + 4 <= bytes.Length); |
| 372 | return (UInt32)(bytes[offset] + (bytes[offset + 1] << 8) + (bytes[offset + 2] << 16) + (bytes[offset + 3] << 24)); | 372 | return BurnCommon.ReadUInt16(bytes, offset) + ((UInt32)BurnCommon.ReadUInt16(bytes, offset + 2) << 16); |
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | /// <summary> | 375 | /// <summary> |
| @@ -378,10 +378,10 @@ namespace WixToolset.Core.Burn.Bundles | |||
| 378 | /// <param name="bytes">Array from which to read.</param> | 378 | /// <param name="bytes">Array from which to read.</param> |
| 379 | /// <param name="offset">Beginning offset from which to read.</param> | 379 | /// <param name="offset">Beginning offset from which to read.</param> |
| 380 | /// <returns>value at offset</returns> | 380 | /// <returns>value at offset</returns> |
| 381 | private static UInt64 ReadUInt64(byte[] bytes, UInt32 offset) | 381 | internal static UInt64 ReadUInt64(byte[] bytes, UInt32 offset) |
| 382 | { | 382 | { |
| 383 | Debug.Assert(offset + 8 <= bytes.Length); | 383 | Debug.Assert(offset + 8 <= bytes.Length); |
| 384 | return BurnCommon.ReadUInt32(bytes, offset) + ((UInt64)(BurnCommon.ReadUInt32(bytes, offset + 4)) << 32); | 384 | return BurnCommon.ReadUInt32(bytes, offset) + ((UInt64)BurnCommon.ReadUInt32(bytes, offset + 4) << 32); |
| 385 | } | 385 | } |
| 386 | } | 386 | } |
| 387 | } | 387 | } |
diff --git a/src/WixToolset.Core.Burn/WixToolset.Core.Burn.csproj b/src/WixToolset.Core.Burn/WixToolset.Core.Burn.csproj index 77e0856a..b0be1d3b 100644 --- a/src/WixToolset.Core.Burn/WixToolset.Core.Burn.csproj +++ b/src/WixToolset.Core.Burn/WixToolset.Core.Burn.csproj | |||
| @@ -15,6 +15,9 @@ | |||
| 15 | <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> | 15 | <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> |
| 16 | <_Parameter1>WixToolset.Core.TestPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9967ec28982f42ee51a47dd5204315975a6ed69294b982146a99a70130a2fa13e226aaddde14c17d1bf3af69e8956d69a86585e74d208efcc5ac98a0686055327b2e87960d3c39bf3a6bc1e572863327d19dbf4fd2616dda124dbea260755a2d1d39d3cf1049ea526493eb2bf996b8ad985e3012308529e5b9b0f5cd5fa04bd</_Parameter1> | 16 | <_Parameter1>WixToolset.Core.TestPackage, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9967ec28982f42ee51a47dd5204315975a6ed69294b982146a99a70130a2fa13e226aaddde14c17d1bf3af69e8956d69a86585e74d208efcc5ac98a0686055327b2e87960d3c39bf3a6bc1e572863327d19dbf4fd2616dda124dbea260755a2d1d39d3cf1049ea526493eb2bf996b8ad985e3012308529e5b9b0f5cd5fa04bd</_Parameter1> |
| 17 | </AssemblyAttribute> | 17 | </AssemblyAttribute> |
| 18 | <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> | ||
| 19 | <_Parameter1>WixToolsetTest.Core.Burn, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a9967ec28982f42ee51a47dd5204315975a6ed69294b982146a99a70130a2fa13e226aaddde14c17d1bf3af69e8956d69a86585e74d208efcc5ac98a0686055327b2e87960d3c39bf3a6bc1e572863327d19dbf4fd2616dda124dbea260755a2d1d39d3cf1049ea526493eb2bf996b8ad985e3012308529e5b9b0f5cd5fa04bd</_Parameter1> | ||
| 20 | </AssemblyAttribute> | ||
| 18 | </ItemGroup> | 21 | </ItemGroup> |
| 19 | 22 | ||
| 20 | <ItemGroup> | 23 | <ItemGroup> |
diff --git a/src/test/WixToolsetTest.Core.Burn/BurnReaderFixture.cs b/src/test/WixToolsetTest.Core.Burn/BurnReaderFixture.cs new file mode 100644 index 00000000..a83da7f6 --- /dev/null +++ b/src/test/WixToolsetTest.Core.Burn/BurnReaderFixture.cs | |||
| @@ -0,0 +1,44 @@ | |||
| 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 | namespace WixToolsetTest.Core.Burn | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using WixToolset.Core.Burn.Bundles; | ||
| 7 | using Xunit; | ||
| 8 | |||
| 9 | public class BurnReaderFixture | ||
| 10 | { | ||
| 11 | [Fact] | ||
| 12 | public void CanReadUInt16Max() | ||
| 13 | { | ||
| 14 | var bytes = new byte[] { 0xFF, 0xFF }; | ||
| 15 | var offset = 0u; | ||
| 16 | |||
| 17 | var result = BurnCommon.ReadUInt16(bytes, offset); | ||
| 18 | |||
| 19 | Assert.Equal(UInt16.MaxValue, result); | ||
| 20 | } | ||
| 21 | |||
| 22 | [Fact] | ||
| 23 | public void CanReadUInt32Max() | ||
| 24 | { | ||
| 25 | var bytes = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF }; | ||
| 26 | var offset = 0u; | ||
| 27 | |||
| 28 | var result = BurnCommon.ReadUInt32(bytes, offset); | ||
| 29 | |||
| 30 | Assert.Equal(UInt32.MaxValue, result); | ||
| 31 | } | ||
| 32 | |||
| 33 | [Fact] | ||
| 34 | public void CanReadUInt64Max() | ||
| 35 | { | ||
| 36 | var bytes = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | ||
| 37 | var offset = 0u; | ||
| 38 | |||
| 39 | var result = BurnCommon.ReadUInt64(bytes, offset); | ||
| 40 | |||
| 41 | Assert.Equal(UInt64.MaxValue, result); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | } | ||
diff --git a/src/test/WixToolsetTest.Core.Burn/WixToolsetTest.Core.Burn.csproj b/src/test/WixToolsetTest.Core.Burn/WixToolsetTest.Core.Burn.csproj new file mode 100644 index 00000000..da0985b1 --- /dev/null +++ b/src/test/WixToolsetTest.Core.Burn/WixToolsetTest.Core.Burn.csproj | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <!-- 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. --> | ||
| 3 | |||
| 4 | <Project Sdk="Microsoft.NET.Sdk"> | ||
| 5 | <PropertyGroup> | ||
| 6 | <TargetFramework>netcoreapp2.1</TargetFramework> | ||
| 7 | <IsPackable>false</IsPackable> | ||
| 8 | <DebugType>embedded</DebugType> | ||
| 9 | </PropertyGroup> | ||
| 10 | |||
| 11 | <PropertyGroup> | ||
| 12 | <NoWarn>NU1701</NoWarn> | ||
| 13 | </PropertyGroup> | ||
| 14 | |||
| 15 | <ItemGroup> | ||
| 16 | <ProjectReference Include="..\..\WixToolset.Core.Burn\WixToolset.Core.Burn.csproj" /> | ||
| 17 | </ItemGroup> | ||
| 18 | |||
| 19 | <ItemGroup> | ||
| 20 | <PackageReference Include="WixBuildTools.TestSupport" Version="4.0.*" /> | ||
| 21 | </ItemGroup> | ||
| 22 | |||
| 23 | <ItemGroup> | ||
| 24 | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" /> | ||
| 25 | <PackageReference Include="xunit" Version="2.4.1" /> | ||
| 26 | <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" PrivateAssets="All" /> | ||
| 27 | </ItemGroup> | ||
| 28 | </Project> | ||
