From: cristy Date: Fri, 9 Jan 2015 12:13:22 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~1472 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=771c884804218f352efd091f15328cebd1696079;p=imagemagick --- diff --git a/coders/aai.c b/coders/aai.c index 0f34b75e4..a069a636a 100644 --- a/coders/aai.c +++ b/coders/aai.c @@ -170,7 +170,7 @@ static Image *ReadAAIImage(const ImageInfo *image_info,ExceptionInfo *exception) for (y=0; y < (ssize_t) image->rows; y++) { count=ReadBlob(image,length,pixels); - if ((size_t) count != length) + if (count != (ssize_t) length) ThrowReaderException(CorruptImageError,"UnableToReadImageData"); p=pixels; q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); diff --git a/coders/bmp.c b/coders/bmp.c index 1df0a492f..d8e4ff85d 100644 --- a/coders/bmp.c +++ b/coders/bmp.c @@ -547,6 +547,8 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception) bmp_info.ba_offset=0; start_position=0; count=ReadBlob(image,2,magick); + if (count != 2) + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); do { PixelInfo diff --git a/coders/dds.c b/coders/dds.c index d8319bd4b..f9a3ed128 100644 --- a/coders/dds.c +++ b/coders/dds.c @@ -2553,7 +2553,7 @@ static void WriteCompressed(Image *image, const size_t count, ComputeWeightedCovariance(count,points,covariance); ComputePrincipleComponent(covariance,&principle); - if (clusterFit == MagickFalse || count == 0) + if ((clusterFit == MagickFalse) || (count == 0)) CompressRangeFit(count,points,map,principle,metric,&start,&end,indices); else CompressClusterFit(count,points,map,principle,metric,&start,&end,indices); diff --git a/coders/jp2.c b/coders/jp2.c index 0ec43c605..27ae32748 100644 --- a/coders/jp2.c +++ b/coders/jp2.c @@ -204,7 +204,7 @@ static OPJ_SIZE_T JP2ReadHandler(void *buffer,OPJ_SIZE_T length,void *context) image=(Image *) context; count=ReadBlob(image,(ssize_t) length,(unsigned char *) buffer); - if (count == 0) + if (count != (ssize_t) length) return((OPJ_SIZE_T) -1); return((OPJ_SIZE_T) count); } diff --git a/coders/pcd.c b/coders/pcd.c index 1586f2975..7c904e942 100644 --- a/coders/pcd.c +++ b/coders/pcd.c @@ -539,7 +539,7 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); count=ReadBlob(image,3*0x800,header); overview=LocaleNCompare((char *) header,"PCD_OPA",7) == 0; - if ((count == 0) || + if ((count != (3*0x800)) || ((LocaleNCompare((char *) header+0x800,"PCD",3) != 0) && (overview ==0))) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); rotate=header[0x0e02] & 0x03; diff --git a/coders/pnm.c b/coders/pnm.c index 5078e4afa..0ed69f143 100644 --- a/coders/pnm.c +++ b/coders/pnm.c @@ -1348,9 +1348,9 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception) Skip to end of line. */ count=ReadBlob(image,1,(unsigned char *) &format); - if (count == 0) + if (count != 1) break; - if ((count != 0) && (format == 'P')) + if (format == 'P') break; } while (format != '\n'); count=ReadBlob(image,1,(unsigned char *) &format); diff --git a/coders/pwp.c b/coders/pwp.c index 00a1d328e..357687d57 100644 --- a/coders/pwp.c +++ b/coders/pwp.c @@ -171,7 +171,7 @@ static Image *ReadPWPImage(const ImageInfo *image_info,ExceptionInfo *exception) if (status == MagickFalse) return((Image *) NULL); count=ReadBlob(pwp_image,5,magick); - if ((count == 0) || (LocaleNCompare((char *) magick,"SFW95",5) != 0)) + if ((count != 5) || (LocaleNCompare((char *) magick,"SFW95",5) != 0)) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); read_info=CloneImageInfo(image_info); (void) SetImageInfoProgressMonitor(read_info,(MagickProgressMonitor) NULL, diff --git a/coders/rle.c b/coders/rle.c index dd77e43c9..6af18f494 100644 --- a/coders/rle.c +++ b/coders/rle.c @@ -209,7 +209,7 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception) Determine if this a RLE file. */ count=ReadBlob(image,2,(unsigned char *) magick); - if ((count == 0) || (memcmp(magick,"\122\314",2) != 0)) + if ((count != 2) || (memcmp(magick,"\122\314",2) != 0)) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); do { diff --git a/coders/tga.c b/coders/tga.c index 8b614791d..852ea9f01 100644 --- a/coders/tga.c +++ b/coders/tga.c @@ -417,7 +417,7 @@ static Image *ReadTGAImage(const ImageInfo *image_info, else { count=ReadBlob(image,1,&runlength); - if (count == 0) + if (count != 1) ThrowReaderException(CorruptImageError,"UnableToReadImageData"); flag=runlength & 0x80; if (flag != 0) diff --git a/coders/tiff.c b/coders/tiff.c index ec27e9d15..54edc9173 100644 --- a/coders/tiff.c +++ b/coders/tiff.c @@ -2063,7 +2063,7 @@ static void TIFFIgnoreTags(TIFF *tiff) i=0; p=tags; ignore=(TIFFFieldInfo *) AcquireQuantumMemory(count,sizeof(*ignore)); - // This also sets field_bit to 0 (FIELD_IGNORE) + /* This also sets field_bit to 0 (FIELD_IGNORE) */ ResetMagickMemory(ignore,0,count*sizeof(*ignore)); while (*p != '\0') { diff --git a/coders/xcf.c b/coders/xcf.c index 577bdcd28..9821bc315 100644 --- a/coders/xcf.c +++ b/coders/xcf.c @@ -1022,7 +1022,7 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception) return((Image *) NULL); } count=ReadBlob(image,14,(unsigned char *) magick); - if ((count == 0) || + if ((count != 14) || (LocaleNCompare((char *) magick,"gimp xcf",8) != 0)) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); (void) ResetMagickMemory(&doc_info,0,sizeof(XCFDocInfo)); diff --git a/coders/xwd.c b/coders/xwd.c index d9b7d13f4..f83b4ef03 100644 --- a/coders/xwd.c +++ b/coders/xwd.c @@ -329,7 +329,7 @@ static Image *ReadXWDImage(const ImageInfo *image_info,ExceptionInfo *exception) for (i=0; i < (ssize_t) header.ncolors; i++) { count=ReadBlob(image,sz_XWDColor,(unsigned char *) &color); - if (count == 0) + if (count != sz_XWDColor) { ximage=(XImage *) RelinquishMagickMemory(ximage); ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile");