From 35f7a90d0130fbcf67e3cc11c49c42aaad1f9603 Mon Sep 17 00:00:00 2001 From: Drew Noakes Date: Fri, 24 Nov 2017 10:54:06 +0000 Subject: [PATCH] Better PNG chunk length error message Via drewnoakes/metadata-extractor#272 --- MetadataExtractor/Formats/Png/PngChunkReader.cs | 2 ++ 1 file changed, 2 insertions(+) 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);