SixLabors/ImageSharp

Image.Load throws AccessViolationException

Metalnem opened this issue · 0 comments

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Description

Image.Load throws AccessViolationException when loading malformed JPG file.

Steps to Reproduce

Run the following code snippet with the path variable containing the path to the file from the attached archive:

Image.Load(path);

You will get the following stack trace:

SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.HuffmanTable.HuffmanTable(SixLabors.Memory.MemoryAllocator memoryAllocator, System.ReadOnlySpan<byte> codeLengths, System.ReadOnlySpan<byte> values = "System.ReadOnlySpan<Byte>[1034377664]")	Unknown
SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.ProcessDefineHuffmanTablesMarker(int remaining = 21)	Unknown
SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.ParseStream(System.IO.Stream stream, bool metadataOnly = false)	Unknown
SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.Decode<SixLabors.ImageSharp.PixelFormats.Rgba32>(System.IO.Stream stream)	Unknown
SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Formats.Jpeg.JpegDecoder.Decode<SixLabors.ImageSharp.PixelFormats.Rgba32>(SixLabors.ImageSharp.Configuration configuration, System.IO.Stream stream)	Unknown
SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Image.Decode<SixLabors.ImageSharp.PixelFormats.Rgba32>(System.IO.Stream stream, SixLabors.ImageSharp.Configuration config)	Unknown
SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Image.WithSeekableStream<System.ValueTuple<System.__Canon, System.__Canon>>(SixLabors.ImageSharp.Configuration config, System.IO.Stream stream, System.Func<System.IO.Stream, (System.__Canon, System.__Canon)> action)	Unknown
SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Image.Load<SixLabors.ImageSharp.PixelFormats.Rgba32>(SixLabors.ImageSharp.Configuration config, System.IO.Stream stream, out SixLabors.ImageSharp.Formats.IImageFormat format = null)	Unknown
SixLabors.ImageSharp.dll!SixLabors.ImageSharp.Image.Load<SixLabors.ImageSharp.PixelFormats.Rgba32>(SixLabors.ImageSharp.Configuration config, byte[] data)	Unknown

System Configuration

  • ImageSharp version: Beta 6
  • Environment (Operating system, version and so on): Windows 10 Pro 1803
  • .NET Framework version: .NET Core 2.2.102

Found via SharpFuzz.