From 54f8bb6ebffb8e6a3bb81cc11cebf25d9ccc93c1 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Thu, 31 Aug 2017 02:08:50 +0200 Subject: [PATCH] fixed #178 --- .../Components/Decoder/OrigJpegScanDecoder.cs | 7 +------ .../Formats/Jpg/JpegDecoderTests.cs | 18 +++++++----------- tests/ImageSharp.Tests/TestImages.cs | 2 +- tests/Images/External | 2 +- ...=> Issue178-BadCoeffsProgressive-Lemon.jpg} | 0 5 files changed, 10 insertions(+), 19 deletions(-) rename tests/Images/Input/Jpg/issues/{Issue178Lemon-ProgressiveWithTooManyCoefficients.jpg => Issue178-BadCoeffsProgressive-Lemon.jpg} (100%) diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.cs index 9bab18d09..a563bcd48 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigJpegScanDecoder.cs @@ -605,12 +605,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder return; } - if (zig > this.zigEnd) - { - throw new ImageFormatException($"Too many coefficients {zig} > {this.zigEnd}"); - } - - if (z != 0) + if (z != 0 && zig <= this.zigEnd) { // b[Unzig[zig]] = z; Block8x8.SetScalarAt(b, this.pointers.Unzig[zig], (short)z); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index adb928654..1a98574d2 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg { TestImages.Jpeg.Progressive.Fb, TestImages.Jpeg.Progressive.Progress, TestImages.Jpeg.Progressive.Festzug, TestImages.Jpeg.Progressive.Bad.BadEOF, - TestImages.Jpeg.Issues.ProgressiveWithTooManyCoefficients178 + TestImages.Jpeg.Issues.BadCoeffsProgressive178 }; public const PixelTypes CommonNonDefaultPixelTypes = PixelTypes.Rgba32 | PixelTypes.Argb32 | PixelTypes.RgbaVector; @@ -69,16 +69,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg private static IImageDecoder OrigJpegDecoder => new OrigJpegDecoder(); private static IImageDecoder PdfJsJpegDecoder => new JpegDecoder(); - - [Fact(Skip = "Doesn't really matter")] - public void ParseStream_BasicPropertiesAreCorrect1_Orig() - { - using (OrigJpegDecoderCore decoder = JpegFixture.ParseStream(TestImages.Jpeg.Progressive.Progress)) - { - VerifyJpeg.VerifyComponentSizes3(decoder.Components, 43, 61, 22, 31, 22, 31); - } - } - + [Fact] public void ParseStream_BasicPropertiesAreCorrect1_PdfJs() { @@ -199,6 +190,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg private void CompareJpegDecodersImpl(TestImageProvider provider, string testName) where TPixel : struct, IPixel { + if (TestEnvironment.RunsOnCI) // Debug only test + { + return; + } + this.Output.WriteLine(provider.SourceFileOrDescription); provider.Utility.TestName = testName; diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index c09cefa48..5737a383c 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.Tests { public const string CriticalEOF214 = "Jpg/issues/Issue214-CriticalEOF.jpg"; public const string Issue159Girl = "Jpg/issues/Issue159Girl.jpg"; - public const string ProgressiveWithTooManyCoefficients178 = "Jpg/issues/Issue178Lemon-ProgressiveWithTooManyCoefficients.jpg"; + public const string BadCoeffsProgressive178 = "Jpg/issues/Issue178-BadCoeffsProgressive-Lemon.jpg"; } public static readonly string[] All = Baseline.All.Concat(Progressive.All).ToArray(); diff --git a/tests/Images/External b/tests/Images/External index d91054b0e..90cd8c2da 160000 --- a/tests/Images/External +++ b/tests/Images/External @@ -1 +1 @@ -Subproject commit d91054b0e00001ea90e3098f7057c741893365c4 +Subproject commit 90cd8c2dae16b18bb99e8c2166da72b3159e58c4 diff --git a/tests/Images/Input/Jpg/issues/Issue178Lemon-ProgressiveWithTooManyCoefficients.jpg b/tests/Images/Input/Jpg/issues/Issue178-BadCoeffsProgressive-Lemon.jpg similarity index 100% rename from tests/Images/Input/Jpg/issues/Issue178Lemon-ProgressiveWithTooManyCoefficients.jpg rename to tests/Images/Input/Jpg/issues/Issue178-BadCoeffsProgressive-Lemon.jpg