Browse Source

Fix #721

af/merge-core
James Jackson-South 7 years ago
parent
commit
77f6c1738f
  1. 3
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
  2. 5
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs
  3. 1
      tests/ImageSharp.Tests/TestImages.cs
  4. 2
      tests/Images/External
  5. 3
      tests/Images/Input/Jpg/issues/Issue721-InvalidAPP0.jpg

3
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -510,7 +510,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// <param name="remaining">The remaining bytes in the segment block.</param>
private void ProcessApplicationHeaderMarker(int remaining)
{
if (remaining < 5)
// We can only decode JFif identifiers.
if (remaining < JFifMarker.Length)
{
// Skip the application header length
this.InputStream.Skip(remaining);

5
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs

@ -25,7 +25,8 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
TestImages.Jpeg.Issues.MultiHuffmanBaseline394,
TestImages.Jpeg.Issues.ExifDecodeOutOfRange694,
TestImages.Jpeg.Issues.InvalidEOI695,
TestImages.Jpeg.Issues.ExifResizeOutOfRange696
TestImages.Jpeg.Issues.ExifResizeOutOfRange696,
TestImages.Jpeg.Issues.InvalidAPP0721
};
public static string[] ProgressiveTestJpegs =
@ -54,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
TestImages.Jpeg.Issues.MissingFF00ProgressiveBedroom159
};
private static readonly Dictionary<string, float> CustomToleranceValues =
private static readonly Dictionary<string, float> CustomToleranceValues =
new Dictionary<string, float>
{
// Baseline:

1
tests/ImageSharp.Tests/TestImages.cs

@ -155,6 +155,7 @@ namespace SixLabors.ImageSharp.Tests
public const string ExifDecodeOutOfRange694 = "Jpg/issues/Issue694-Decode-Exif-OutOfRange.jpg";
public const string InvalidEOI695 = "Jpg/issues/Issue695-Invalid-EOI.jpg";
public const string ExifResizeOutOfRange696 = "Jpg/issues/Issue696-Resize-Exif-OutOfRange.jpg";
public const string InvalidAPP0721 = "Jpg/issues/Issue721-InvalidAPP0.jpg";
}
public static readonly string[] All = Baseline.All.Concat(Progressive.All).ToArray();

2
tests/Images/External

@ -1 +1 @@
Subproject commit 7f4d2d64c6b820ca2b6827e6a8540a1013305ccf
Subproject commit 5f3cbd839fbbffae615d294d1dabafdcabc64cf9

3
tests/Images/Input/Jpg/issues/Issue721-InvalidAPP0.jpg

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9775b7b975422d48a192d54dce140c1df19a181da9889eb99ee7d4331078b460
size 1225163
Loading…
Cancel
Save