Skip to content

Commit

Permalink
https://github.com/ImageMagick/ImageMagick/issues/1553
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Apr 20, 2019
1 parent 112760b commit c78993d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions coders/xwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ static Image *ReadXWDImage(const ImageInfo *image_info,ExceptionInfo *exception)
ThrowReaderException(CorruptImageError,"FileFormatVersionMismatch");
if (header.header_size < sz_XWDheader)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
if ((MagickSizeType) header.xoffset >= GetBlobSize(image))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
switch (header.visual_class)
{
case StaticGray:
Expand All @@ -251,7 +253,7 @@ static Image *ReadXWDImage(const ImageInfo *image_info,ExceptionInfo *exception)
case PseudoColor:
{
if ((header.bits_per_pixel < 1) || (header.bits_per_pixel > 15) ||
(header.ncolors == 0))
(header.colormap_entries == 0))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
break;
}
Expand Down Expand Up @@ -318,8 +320,6 @@ static Image *ReadXWDImage(const ImageInfo *image_info,ExceptionInfo *exception)
default:
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
}
if (header.ncolors > 65535)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
if (((header.bitmap_pad % 8) != 0) || (header.bitmap_pad > 32))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
length=(size_t) (header.header_size-sz_XWDheader);
Expand Down Expand Up @@ -387,8 +387,10 @@ static Image *ReadXWDImage(const ImageInfo *image_info,ExceptionInfo *exception)
XWDColor
color;

colors=(XColor *) AcquireQuantumMemory((size_t) header.ncolors,
sizeof(*colors));
length=(size_t) header.ncolors;
if (length > ((~0UL)/sizeof(*colors)))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
colors=(XColor *) AcquireQuantumMemory(length,sizeof(*colors));
if (colors == (XColor *) NULL)
{
ximage=(XImage *) RelinquishMagickMemory(ximage);
Expand Down Expand Up @@ -689,6 +691,7 @@ ModuleExport size_t RegisterXWDImage(void)
entry->encoder=(EncodeImageHandler *) WriteXWDImage;
#endif
entry->magick=(IsImageFormatHandler *) IsXWD;
entry->flags|=CoderDecoderSeekableStreamFlag;
entry->flags^=CoderAdjoinFlag;
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
Expand Down

0 comments on commit c78993d

Please sign in to comment.