}
#endif
-static inline size_t MagickMax(const size_t x,const size_t y)
-{
- if (x > y)
- return(x);
- return(y);
-}
-
-static inline size_t MagickMin(const size_t x,const size_t y)
-{
- if (x < y)
- return(x);
- return(y);
-}
-
static void PushRunlengthPacket(Image *image,const unsigned char *pixels,
size_t *length,PixelInfo *pixel,ExceptionInfo *exception)
{
i;
size_t
+ compress_extent,
length,
packet_size;
/*
Get the keyword.
*/
+ length=MaxTextExtent;
p=keyword;
do
{
break;
p=options+strlen(options);
}
- if (options == (char *) NULL)
- ThrowReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
*p++=(char) c;
c=ReadBlobByte(image);
if (c == '\\')
if (*options != '{')
if (isspace((int) ((unsigned char) c)) != 0)
break;
- } }
+ }
+ if (options == (char *) NULL)
+ ThrowReaderException(ResourceLimitError,
+ "MemoryAllocationFailed");
+ }
*p='\0';
if (*options == '{')
(void) CopyMagickString(options,options+1,strlen(options));
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));
/*
Allocate image pixels.
*/
packet_size+=quantum_info->depth/8;
if (image->compression == RLECompression)
packet_size++;
- length=image->columns;
- length=MagickMax(MagickMax(BZipMaxExtent(packet_size*image->columns),
- LZMAMaxExtent(packet_size*image->columns)),ZipMaxExtent(packet_size*
- image->columns));
- compress_pixels=(unsigned char *) AcquireQuantumMemory(length,
+ compress_extent=MagickMax(MagickMax(BZipMaxExtent(packet_size*
+ image->columns),LZMAMaxExtent(packet_size*image->columns)),
+ ZipMaxExtent(packet_size*image->columns));
+ compress_pixels=(unsigned char *) AcquireQuantumMemory(compress_extent,
sizeof(*compress_pixels));
if (compress_pixels == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
bzip_info.avail_out=(unsigned int) (packet_size*image->columns);
do
{
+ int
+ code;
+
if (bzip_info.avail_in == 0)
{
bzip_info.next_in=(char *) compress_pixels;
length=(size_t) BZipMaxExtent(packet_size*image->columns);
if (version != 0.0)
length=(size_t) ReadBlobMSBLong(image);
+ if (length > compress_extent)
+ ThrowReaderException(CorruptImageError,
+ "UnableToReadImageData");
bzip_info.avail_in=(unsigned int) ReadBlob(image,length,
(unsigned char *) bzip_info.next_in);
}
- if (BZ2_bzDecompress(&bzip_info) == BZ_STREAM_END)
+ code=BZ2_bzDecompress(&bzip_info);
+ if (code < 0)
+ {
+ status=MagickFalse;
+ break;
+ }
+ if (code == BZ_STREAM_END)
break;
} while (bzip_info.avail_out != 0);
(void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,
{
lzma_info.next_in=compress_pixels;
length=(size_t) ReadBlobMSBLong(image);
+ if (length > compress_extent)
+ ThrowReaderException(CorruptImageError,
+ "UnableToReadImageData");
lzma_info.avail_in=(unsigned int) ReadBlob(image,length,
(unsigned char *) lzma_info.next_in);
}
zip_info.avail_out=(uInt) (packet_size*image->columns);
do
{
+ int
+ code;
+
if (zip_info.avail_in == 0)
{
zip_info.next_in=compress_pixels;
length=(size_t) ZipMaxExtent(packet_size*image->columns);
if (version != 0.0)
length=(size_t) ReadBlobMSBLong(image);
+ if (length > compress_extent)
+ ThrowReaderException(CorruptImageError,
+ "UnableToReadImageData");
zip_info.avail_in=(unsigned int) ReadBlob(image,length,
zip_info.next_in);
}
- if (inflate(&zip_info,Z_SYNC_FLUSH) == Z_STREAM_END)
+ code=inflate(&zip_info,Z_SYNC_FLUSH);
+ if (code < 0)
+ {
+ status=MagickFalse;
+ break;
+ }
+ if (code == Z_STREAM_END)
break;
} while (zip_info.avail_out != 0);
(void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,
entry->decoder=(DecodeImageHandler *) ReadMIFFImage;
entry->encoder=(EncodeImageHandler *) WriteMIFFImage;
entry->magick=(IsImageFormatHandler *) IsMIFF;
- entry->seekable_stream=MagickTrue;
+ entry->flags|=CoderSeekableStreamFlag;
entry->description=ConstantString("Magick Image File Format");
if (*version != '\0')
entry->version=ConstantString(version);
packet_size+=quantum_info->depth/8;
if (compression == RLECompression)
packet_size++;
- length=image->columns;
length=MagickMax(BZipMaxExtent(packet_size*image->columns),ZipMaxExtent(
packet_size*image->columns));
if ((compression == BZipCompression) || (compression == ZipCompression))