@@ -4053,6 +4053,12 @@ static Image *ReadPNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
40534053 if (count < 8 || memcmp (magic_number ,"\211PNG\r\n\032\n" ,8 ) != 0 )
40544054 ThrowReaderException (CorruptImageError ,"ImproperImageHeader" );
40554055
4056+ /*
4057+ Verify that file size large enough to contain a PNG datastream.
4058+ */
4059+ if (GetBlobSize (image ) < 61 )
4060+ ThrowReaderException (CorruptImageError ,"InsufficientImageDataInFile" );
4061+
40564062 /*
40574063 Allocate a MngInfo structure.
40584064 */
@@ -4933,6 +4939,12 @@ static Image *ReadJNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
49334939 if (count < 8 || memcmp (magic_number ,"\213JNG\r\n\032\n" ,8 ) != 0 )
49344940 ThrowReaderException (CorruptImageError ,"ImproperImageHeader" );
49354941
4942+ /*
4943+ Verify that file size large enough to contain a JNG datastream.
4944+ */
4945+ if (GetBlobSize (image ) < 147 )
4946+ ThrowReaderException (CorruptImageError ,"InsufficientImageDataInFile" );
4947+
49364948 /* Allocate a MngInfo structure. */
49374949
49384950 mng_info = (MngInfo * ) AcquireMagickMemory (sizeof (* mng_info ));
@@ -7480,7 +7492,7 @@ ModuleExport size_t RegisterPNGImage(void)
74807492#endif
74817493
74827494 entry = SetMagickInfo ("MNG" );
7483- entry -> seekable_stream = MagickTrue ; /* To do: eliminate this. */
7495+ entry -> seekable_stream = MagickTrue ;
74847496
74857497#if defined(MAGICKCORE_PNG_DELEGATE )
74867498 entry -> decoder = (DecodeImageHandler * ) ReadMNGImage ;
@@ -7505,6 +7517,7 @@ ModuleExport size_t RegisterPNGImage(void)
75057517#endif
75067518
75077519 entry -> magick = (IsImageFormatHandler * ) IsPNG ;
7520+ entry -> seekable_stream = MagickTrue ;
75087521 entry -> adjoin = MagickFalse ;
75097522 entry -> description = ConstantString ("Portable Network Graphics" );
75107523 entry -> mime_type = ConstantString ("image/png" );
@@ -7524,6 +7537,7 @@ ModuleExport size_t RegisterPNGImage(void)
75247537#endif
75257538
75267539 entry -> magick = (IsImageFormatHandler * ) IsPNG ;
7540+ entry -> seekable_stream = MagickTrue ;
75277541 entry -> adjoin = MagickFalse ;
75287542 entry -> description = ConstantString (
75297543 "8-bit indexed with optional binary transparency" );
@@ -7554,6 +7568,7 @@ ModuleExport size_t RegisterPNGImage(void)
75547568#endif
75557569
75567570 entry -> magick = (IsImageFormatHandler * ) IsPNG ;
7571+ entry -> seekable_stream = MagickTrue ;
75577572 entry -> adjoin = MagickFalse ;
75587573 entry -> description = ConstantString ("opaque or binary transparent 24-bit RGB" );
75597574 entry -> mime_type = ConstantString ("image/png" );
@@ -7568,6 +7583,7 @@ ModuleExport size_t RegisterPNGImage(void)
75687583#endif
75697584
75707585 entry -> magick = (IsImageFormatHandler * ) IsPNG ;
7586+ entry -> seekable_stream = MagickTrue ;
75717587 entry -> adjoin = MagickFalse ;
75727588 entry -> description = ConstantString ("opaque or transparent 32-bit RGBA" );
75737589 entry -> mime_type = ConstantString ("image/png" );
@@ -7582,6 +7598,7 @@ ModuleExport size_t RegisterPNGImage(void)
75827598#endif
75837599
75847600 entry -> magick = (IsImageFormatHandler * ) IsPNG ;
7601+ entry -> seekable_stream = MagickTrue ;
75857602 entry -> adjoin = MagickFalse ;
75867603 entry -> description = ConstantString ("opaque or binary transparent 48-bit RGB" );
75877604 entry -> mime_type = ConstantString ("image/png" );
@@ -7596,6 +7613,7 @@ ModuleExport size_t RegisterPNGImage(void)
75967613#endif
75977614
75987615 entry -> magick = (IsImageFormatHandler * ) IsPNG ;
7616+ entry -> seekable_stream = MagickTrue ;
75997617 entry -> adjoin = MagickFalse ;
76007618 entry -> description = ConstantString ("opaque or transparent 64-bit RGBA" );
76017619 entry -> mime_type = ConstantString ("image/png" );
@@ -7610,6 +7628,7 @@ ModuleExport size_t RegisterPNGImage(void)
76107628#endif
76117629
76127630 entry -> magick = (IsImageFormatHandler * ) IsPNG ;
7631+ entry -> seekable_stream = MagickTrue ;
76137632 entry -> adjoin = MagickFalse ;
76147633 entry -> description = ConstantString (
76157634 "PNG inheriting bit-depth, color-type from original if possible" );
@@ -7627,6 +7646,7 @@ ModuleExport size_t RegisterPNGImage(void)
76277646#endif
76287647
76297648 entry -> magick = (IsImageFormatHandler * ) IsJNG ;
7649+ entry -> seekable_stream = MagickTrue ;
76307650 entry -> adjoin = MagickFalse ;
76317651 entry -> description = ConstantString ("JPEG Network Graphics" );
76327652 entry -> mime_type = ConstantString ("image/x-jng" );
0 commit comments