Skip to content
Permalink
Browse files Browse the repository at this point in the history
...
  • Loading branch information
Cristy committed Jul 3, 2017
1 parent 948356e commit aa84944
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion coders/png.c
Expand Up @@ -4053,6 +4053,12 @@ static Image *ReadPNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
if (count < 8 || memcmp(magic_number,"\211PNG\r\n\032\n",8) != 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");

/*
Verify that file size large enough to contain a PNG datastream.
*/
if (GetBlobSize(image) < 61)
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");

/*
Allocate a MngInfo structure.
*/
Expand Down Expand Up @@ -4933,6 +4939,12 @@ static Image *ReadJNGImage(const ImageInfo *image_info,ExceptionInfo *exception)
if (count < 8 || memcmp(magic_number,"\213JNG\r\n\032\n",8) != 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");

/*
Verify that file size large enough to contain a JNG datastream.
*/
if (GetBlobSize(image) < 147)
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");

/* Allocate a MngInfo structure. */

mng_info=(MngInfo *) AcquireMagickMemory(sizeof(*mng_info));
Expand Down Expand Up @@ -7480,7 +7492,7 @@ ModuleExport size_t RegisterPNGImage(void)
#endif

entry=SetMagickInfo("MNG");
entry->seekable_stream=MagickTrue; /* To do: eliminate this. */
entry->seekable_stream=MagickTrue;

#if defined(MAGICKCORE_PNG_DELEGATE)
entry->decoder=(DecodeImageHandler *) ReadMNGImage;
Expand All @@ -7505,6 +7517,7 @@ ModuleExport size_t RegisterPNGImage(void)
#endif

entry->magick=(IsImageFormatHandler *) IsPNG;
entry->seekable_stream=MagickTrue;
entry->adjoin=MagickFalse;
entry->description=ConstantString("Portable Network Graphics");
entry->mime_type=ConstantString("image/png");
Expand All @@ -7524,6 +7537,7 @@ ModuleExport size_t RegisterPNGImage(void)
#endif

entry->magick=(IsImageFormatHandler *) IsPNG;
entry->seekable_stream=MagickTrue;
entry->adjoin=MagickFalse;
entry->description=ConstantString(
"8-bit indexed with optional binary transparency");
Expand Down Expand Up @@ -7554,6 +7568,7 @@ ModuleExport size_t RegisterPNGImage(void)
#endif

entry->magick=(IsImageFormatHandler *) IsPNG;
entry->seekable_stream=MagickTrue;
entry->adjoin=MagickFalse;
entry->description=ConstantString("opaque or binary transparent 24-bit RGB");
entry->mime_type=ConstantString("image/png");
Expand All @@ -7568,6 +7583,7 @@ ModuleExport size_t RegisterPNGImage(void)
#endif

entry->magick=(IsImageFormatHandler *) IsPNG;
entry->seekable_stream=MagickTrue;
entry->adjoin=MagickFalse;
entry->description=ConstantString("opaque or transparent 32-bit RGBA");
entry->mime_type=ConstantString("image/png");
Expand All @@ -7582,6 +7598,7 @@ ModuleExport size_t RegisterPNGImage(void)
#endif

entry->magick=(IsImageFormatHandler *) IsPNG;
entry->seekable_stream=MagickTrue;
entry->adjoin=MagickFalse;
entry->description=ConstantString("opaque or binary transparent 48-bit RGB");
entry->mime_type=ConstantString("image/png");
Expand All @@ -7596,6 +7613,7 @@ ModuleExport size_t RegisterPNGImage(void)
#endif

entry->magick=(IsImageFormatHandler *) IsPNG;
entry->seekable_stream=MagickTrue;
entry->adjoin=MagickFalse;
entry->description=ConstantString("opaque or transparent 64-bit RGBA");
entry->mime_type=ConstantString("image/png");
Expand All @@ -7610,6 +7628,7 @@ ModuleExport size_t RegisterPNGImage(void)
#endif

entry->magick=(IsImageFormatHandler *) IsPNG;
entry->seekable_stream=MagickTrue;
entry->adjoin=MagickFalse;
entry->description=ConstantString(
"PNG inheriting bit-depth, color-type from original if possible");
Expand All @@ -7627,6 +7646,7 @@ ModuleExport size_t RegisterPNGImage(void)
#endif

entry->magick=(IsImageFormatHandler *) IsJNG;
entry->seekable_stream=MagickTrue;
entry->adjoin=MagickFalse;
entry->description=ConstantString("JPEG Network Graphics");
entry->mime_type=ConstantString("image/x-jng");
Expand Down

0 comments on commit aa84944

Please sign in to comment.