Skip to content

Image.Load throws DivideByZeroException #821

Description

@Metalnem

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 DivideByZeroException 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:

System.DivideByZeroException: Attempted to divide by zero.
   at SixLabors.ImageSharp.Formats.Jpeg.Components.SizeExtensions.DivideBy(Size a, Size b)
   at SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.JpegComponent.Init()
   at SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.JpegFrame.InitComponents()
   at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.ProcessStartOfFrameMarker(Int32 remaining, JpegFileMarker& frameMarker, Boolean metadataOnly)
   at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.ParseStream(Stream stream, Boolean metadataOnly)
   at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoderCore.Decode[TPixel](Stream stream)
   at SixLabors.ImageSharp.Formats.Jpeg.JpegDecoder.Decode[TPixel](Configuration configuration, Stream stream)
   at SixLabors.ImageSharp.Image.Decode[TPixel](Stream stream, Configuration config)
   at SixLabors.ImageSharp.Image.WithSeekableStream[T](Configuration config, Stream stream, Func`2 action)
   at SixLabors.ImageSharp.Image.Load[TPixel](Configuration config, Stream stream, IImageFormat& format)
   at SixLabors.ImageSharp.Image.Load[TPixel](Configuration config, Byte[] data)

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.

Activity

  1. changed the title [-]Image.Load throws DivideByZeroException (1)[/-] [+]Image.Load throws DivideByZeroException[/+] on Jan 28, 2019
  2. added this to the 1.0.0-rc1 milestone on Feb 14, 2019
  3. added a commit that references this issue on Feb 15, 2019
    903e4cd
  4. added a commit that references this issue on Nov 11, 2019
    2e241f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions