Skip to content

Get "Invalid PNG data." exception during Identify phase of loading PNG image when image contains sBIT chunk #2018

@flew2bits

Description

@flew2bits

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

ImageSharp version

v2.0.0

Other ImageSharp packages and versions

ImageSharp.Drawing v1.0.0beta14

Environment (Operating system, version and so on)

Windows 10, Rider

.NET Framework version

6.0.1

Description

When loading an image that contains an sBIT chunk, the Identify phase throws an exception stating that the data is invalid. The switch statement in the identify function (around line 250 of PngDecoderCore.cs) does not include the PngChunkType.SignificantBits as a case, nor does it have a default clause. Adding a default clause as follows fixes the issue:

default: this.SkipChunkDataAndCrc(chunk); break;

I may try to submit a PR if I can figure out how to do so.

Unfortunately, I don't have permission to upload the image that is causing this problem.

Steps to Reproduce

Image.Load(stream) from a stream that has a PNG with a sBIT chunk.

Images

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions