% July 1992 %
% %
% %
-% Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
image->resolution.x=(double) pcx_info.horizontal_resolution;
image->resolution.y=(double) pcx_info.vertical_resolution;
image->colors=16;
+ if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
+ if (image->scene >= (image_info->scene+image_info->number_scenes-1))
+ break;
+ status=SetImageExtent(image,image->columns,image->rows,exception);
+ if (status == MagickFalse)
+ ThrowPCXException(exception->severity,exception->reason);
+ (void) SetImageBackgroundColor(image,exception);
+ (void) memset(pcx_colormap,0,sizeof(pcx_colormap));
count=ReadBlob(image,3*image->colors,pcx_colormap);
if (count != (ssize_t) (3*image->colors))
ThrowPCXException(CorruptImageError,"ImproperImageHeader");
pcx_info.planes=(unsigned char) ReadBlobByte(image);
if (pcx_info.planes == 0)
ThrowPCXException(CorruptImageError,"ImproperImageHeader");
+ if (pcx_info.planes > 6)
+ ThrowPCXException(CorruptImageError,"ImproperImageHeader");
if ((pcx_info.bits_per_pixel*pcx_info.planes) >= 64)
ThrowPCXException(CorruptImageError,"ImproperImageHeader");
one=1;
pcx_info.vertical_screensize=ReadBlobLSBShort(image);
for (i=0; i < 54; i++)
(void) ReadBlobByte(image);
- if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
- if (image->scene >= (image_info->scene+image_info->number_scenes-1))
- break;
- status=SetImageExtent(image,image->columns,image->rows,exception);
- if (status == MagickFalse)
- return(DestroyImageList(image));
/*
Read image data.
*/
pixel_info=RelinquishVirtualMemory(pixel_info);
ThrowPCXException(ResourceLimitError,"MemoryAllocationFailed");
}
+ (void) memset(scanline,0,(size_t) MagickMax(image->columns,
+ pcx_info.bytes_per_line)*MagickMax(8,pcx_info.planes)*sizeof(*scanline));
pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);
+ (void) memset(pixels,0,(size_t) pcx_packets*(2*sizeof(*pixels)));
/*
Uncompress image data.
*/
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
+ if ((image->columns > 65535UL) || (image->rows > 65535UL))
+ ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
(void) TransformImageColorspace(image,sRGBColorspace,exception);
page_table=(MagickOffsetType *) NULL;
if ((LocaleCompare(image_info->magick,"DCX") == 0) ||
if (image->alpha_trait != UndefinedPixelTrait)
pcx_info.planes++;
}
- pcx_info.bytes_per_line=(unsigned short) (((size_t) image->columns*
- pcx_info.bits_per_pixel+7)/8);
+ length=(((size_t) image->columns*pcx_info.bits_per_pixel+7)/8);
+ if (length > 65535UL)
+ ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
+ pcx_info.bytes_per_line=(unsigned short) length;
pcx_info.palette_info=1;
pcx_info.colormap_signature=0x0c;
/*
length=(size_t) pcx_info.bytes_per_line;
pixel_info=AcquireVirtualMemory(length,pcx_info.planes*sizeof(*pixels));
if (pixel_info == (MemoryInfo *) NULL)
- ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
+ {
+ pcx_colormap=(unsigned char *) RelinquishMagickMemory(pcx_colormap);
+ if (page_table != (MagickOffsetType *) NULL)
+ page_table=(MagickOffsetType *) RelinquishMagickMemory(page_table);
+ ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
+ }
pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);
q=pixels;
if ((image->storage_class == DirectClass) || (image->colors > 256))
break;
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
- image->rows);
+ status=SetImageProgress(image,SaveImageTag,(MagickOffsetType)
+ y,image->rows);
if (status == MagickFalse)
break;
}
page_table[scene+1]=0;
offset=SeekBlob(image,0L,SEEK_SET);
if (offset < 0)
- ThrowWriterException(CorruptImageError,"ImproperImageHeader");
+ {
+ page_table=(MagickOffsetType *) RelinquishMagickMemory(page_table);
+ ThrowWriterException(CorruptImageError,"ImproperImageHeader");
+ }
(void) WriteBlobLSBLong(image,0x3ADE68B1L);
for (i=0; i <= (ssize_t) scene; i++)
(void) WriteBlobLSBLong(image,(unsigned int) page_table[i]);