From 89f839d02a8f261c94f7f7075c3cf90724802958 Mon Sep 17 00:00:00 2001 From: cristy Date: Sun, 25 Jan 2015 17:32:32 +0000 Subject: [PATCH] --- coders/miff.c | 22 ++++++++++++++++++++-- coders/pdb.c | 10 +++++++++- coders/vicar.c | 2 ++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/coders/miff.c b/coders/miff.c index 8e8ea0429..e517296ef 100644 --- a/coders/miff.c +++ b/coders/miff.c @@ -1377,6 +1377,9 @@ static Image *ReadMIFFImage(const ImageInfo *image_info, 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; @@ -1389,7 +1392,13 @@ static Image *ReadMIFFImage(const ImageInfo *image_info, 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, @@ -1439,6 +1448,9 @@ static Image *ReadMIFFImage(const ImageInfo *image_info, zip_info.avail_out=(uInt) (packet_size*image->columns); do { + int + code; + if (zip_info.avail_in == 0) { zip_info.next_in=compress_pixels; @@ -1451,7 +1463,13 @@ static Image *ReadMIFFImage(const ImageInfo *image_info, 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, diff --git a/coders/pdb.c b/coders/pdb.c index 2a63a0ab0..f482c7769 100644 --- a/coders/pdb.c +++ b/coders/pdb.c @@ -369,7 +369,15 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception) ThrowReaderException(CorruptImageError,"CorruptImage"); } num_pad_bytes = (size_t) (img_offset - TellBlob( image )); - while (num_pad_bytes--) ReadBlobByte( image ); + while (num_pad_bytes-- != 0) + { + int + c; + + c=ReadBlobByte(image); + if (c == EOF) + break; + } /* Read image header. */ diff --git a/coders/vicar.c b/coders/vicar.c index 345c6c5f5..83fdfb019 100644 --- a/coders/vicar.c +++ b/coders/vicar.c @@ -276,6 +276,8 @@ static Image *ReadVICARImage(const ImageInfo *image_info, while (count < (ssize_t) length) { c=ReadBlobByte(image); + if (c == EOF) + break; count++; } if ((image->columns == 0) || (image->rows == 0)) -- 2.40.0