Browse Source

Throw exception when malformed apple png chunk is detected (#410)

pull/1574/head
Brian Popow 6 years ago
parent
commit
e30dcc8e46
  1. 7
      src/ImageSharp/Formats/Png/PngDecoderCore.cs

7
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -9,7 +9,7 @@ using System.IO.Compression;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats.Png.Chunks;
using SixLabors.ImageSharp.Formats.Png.Filters;
using SixLabors.ImageSharp.Formats.Png.Zlib;
@ -215,6 +215,9 @@ namespace SixLabors.ImageSharp.Formats.Png
case PngChunkType.End:
this.isEndChunkReached = true;
break;
case PngChunkType.MalformedApple:
PngThrowHelper.ThrowInvalidChunkType("Malformed Apple PNG detected! This PNG file is not conform to the specification and cannot be decoded.");
break;
}
}
finally
@ -1039,7 +1042,7 @@ namespace SixLabors.ImageSharp.Formats.Png
var uncompressedBytes = new List<byte>();
// Note: this uses the a buffer which is only 4 bytes long to read the stream, maybe allocating a larger buffer makes sense here.
// Note: this uses a buffer which is only 4 bytes long to read the stream, maybe allocating a larger buffer makes sense here.
int bytesRead = inflateStream.CompressedStream.Read(this.buffer, 0, this.buffer.Length);
while (bytesRead != 0)
{

Loading…
Cancel
Save