From: cristy Date: Sun, 15 Feb 2015 13:22:11 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~1286 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64b17a6c9285da37de815495da4cb884cf4f8294;p=imagemagick --- diff --git a/coders/palm.c b/coders/palm.c index f95ae8cb6..075fd5dc9 100644 --- a/coders/palm.c +++ b/coders/palm.c @@ -255,10 +255,6 @@ static Image *ReadPALMImage(const ImageInfo *image_info, register Quantum *q; - ssize_t - count, - y; - size_t bytes_per_row, flags, @@ -277,6 +273,10 @@ static Image *ReadPALMImage(const ImageInfo *image_info, size, bit; + ssize_t + count, + y; + unsigned char *lastrow, *one_row, @@ -317,13 +317,19 @@ static Image *ReadPALMImage(const ImageInfo *image_info, bytes_per_row=ReadBlobMSBShort(image); flags=ReadBlobMSBShort(image); bits_per_pixel=(size_t) ReadBlobByte(image); - if ((bits_per_pixel == 0) || (bits_per_pixel > 16)) - ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + if ((bits_per_pixel != 1) && (bits_per_pixel != 2) && + (bits_per_pixel != 4) && (bits_per_pixel != 8) && + (bits_per_pixel != 16)) + ThrowReaderException(CorruptImageError,"UnrecognizedBitsPerPixel"); version=(size_t) ReadBlobByte(image); (void) version; nextDepthOffset=(size_t) ReadBlobMSBShort(image); transparentIndex=(size_t) ReadBlobByte(image); compressionType=(size_t) ReadBlobByte(image); + if ((compressionType != PALM_COMPRESSION_NONE) && + (compressionType != PALM_COMPRESSION_SCANLINE ) && + (compressionType != PALM_COMPRESSION_RLE)) + ThrowReaderException(CorruptImageError,"UnrecognizedImageCompression"); pad=ReadBlobMSBShort(image); (void) pad; /* @@ -391,6 +397,14 @@ static Image *ReadPALMImage(const ImageInfo *image_info, image->storage_class=PseudoClass; image->depth=8; } + if (image_info->ping != MagickFalse) + { + (void) CloseBlob(image); + return(image); + } + status=SetImageExtent(image,image->columns,image->rows); + if (status == MagickFalse) + return(DestroyImageList(image)); one_row=(unsigned char *) AcquireQuantumMemory(MagickMax(bytes_per_row, 2*image->columns),sizeof(*one_row)); if (one_row == (unsigned char *) NULL) @@ -965,10 +979,8 @@ static MagickBooleanType WritePALMImage(const ImageInfo *image_info, if (GetNextImageInList(image) == (Image *) NULL) break; /* padding to 4 byte word */ - for (cc = (GetBlobSize(image))%4; cc > 0; cc--) - { + for (cc=(GetBlobSize(image)) % 4; cc > 0; cc--) (void) WriteBlobByte(image,0); - } /* write nextDepthOffset and return to end of image */ offset=SeekBlob(image,currentOffset+10,SEEK_SET); nextDepthOffset=(size_t) ((GetBlobSize(image)-currentOffset)/4);