From 7ae25f84f4c4de7bf22c82f4e48f4d3a77dc580a Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 22 Jun 2018 21:40:37 +1000 Subject: [PATCH] Fix #624 --- .../Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs | 3 ++- .../Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs index 34a6e2f0f..61ab47bdf 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/GolangJpegDecoderCore.cs @@ -338,6 +338,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort break; case JpegConstants.Markers.DHT: + if (metadataOnly) { this.InputProcessor.Skip(remaining); @@ -721,7 +722,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort { if (remaining < 17) { - throw new ImageFormatException("DHT has wrong length"); + throw new ImageFormatException($"DHT has wrong length. {remaining}"); } this.InputProcessor.ReadFull(this.Temp, 0, 17); diff --git a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs index 937439ed0..55435e3be 100644 --- a/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/PdfJsPort/PdfJsJpegDecoderCore.cs @@ -270,6 +270,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort } case JpegConstants.Markers.DHT: + if (metadataOnly) { this.InputStream.Skip(remaining); @@ -698,11 +699,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort /// The remaining bytes in the segment block. private void ProcessDefineHuffmanTablesMarker(int remaining) { - if (remaining < 17) - { - throw new ImageFormatException($"DHT has wrong length: {remaining}"); - } - using (IManagedByteBuffer huffmanData = this.configuration.MemoryAllocator.AllocateCleanManagedByteBuffer(256)) { ref byte huffmanDataRef = ref MemoryMarshal.GetReference(huffmanData.GetSpan());