diff --git a/MetadataExtractor/Formats/Png/PngChunkReader.cs b/MetadataExtractor/Formats/Png/PngChunkReader.cs index c682ba6da..328d46465 100644 --- a/MetadataExtractor/Formats/Png/PngChunkReader.cs +++ b/MetadataExtractor/Formats/Png/PngChunkReader.cs @@ -88,6 +88,8 @@ public IEnumerable Extract([NotNull] SequentialReader reader, [CanBeNu { // Process the next chunk. var chunkDataLength = reader.GetInt32(); + if (chunkDataLength < 0) + throw new PngProcessingException("PNG chunk length exceeds maximum"); var chunkType = new PngChunkType(reader.GetBytes(4)); var willStoreChunk = desiredChunkTypes == null || desiredChunkTypes.Contains(chunkType); var chunkData = reader.GetBytes(chunkDataLength);