diff --git a/inc/Data/Driver/Metadata/PngExifReader.php b/inc/Data/Driver/Metadata/PngExifReader.php index 07a9cd7c..726c5214 100644 --- a/inc/Data/Driver/Metadata/PngExifReader.php +++ b/inc/Data/Driver/Metadata/PngExifReader.php @@ -4,7 +4,8 @@ namespace Vichan\Data\Driver\Metadata; class PngExifReader implements ExifReader { // Chunks larger than this will be ignored. - private const MAX_CHUNK_SIZE = 1048576; // 1 MB + private const MAX_CHUNK_SIZE = 1048576; // 1 MB. + private const MAX_CHUNK_COUNT = 32; // 1 MB private const ORIENTATION_TAG_ID = 0x0112; // Exif data type identifier. private const TYPE_SHORT = 0x3; @@ -111,7 +112,7 @@ class PngExifReader implements ExifReader { // Loop through the PNG's chunks. Byte 0-3 is length, Byte 4-7 is type. $chunkHeader = \fread($fd, 8); - while ($chunkHeader) { + for ($i = 0; $chunkHeader && $i < self::MAX_CHUNK_COUNT; $i++) { // Extract length and type from binary data. $chunk = @\unpack('Nsize/a4type', $chunkHeader);