From f0e3ae646552eb481269954c25c811ef3076c901 Mon Sep 17 00:00:00 2001 From: Daniel Helsing Date: Sun, 5 May 2024 14:43:06 +0200 Subject: [PATCH] Fixed PNG compressed iTXt chunk --- MetadataExtractor/Formats/Png/PngMetadataReader.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MetadataExtractor/Formats/Png/PngMetadataReader.cs b/MetadataExtractor/Formats/Png/PngMetadataReader.cs index ad4ecb46c..4601fbc9f 100644 --- a/MetadataExtractor/Formats/Png/PngMetadataReader.cs +++ b/MetadataExtractor/Formats/Png/PngMetadataReader.cs @@ -264,7 +264,9 @@ private static IEnumerable ProcessChunk(PngChunk chunk) { if (compressionMethod == 0) { - if (!TryDeflate(bytes, bytesLeft, out textBytes, out string? errorMessage)) + reader.Skip(2); // Skip over the zlib header bytes (78 9C) + bytesLeft -= 2; + if (!TryDeflate(reader.GetBytes(bytesLeft), bytesLeft, out textBytes, out string? errorMessage)) { var directory = new PngDirectory(PngChunkType.iTXt); directory.AddError($"Exception decompressing PNG {nameof(PngChunkType.iTXt)} chunk with keyword \"{keyword}\": {errorMessage}");