From: Cristy Date: Wed, 24 Apr 2019 22:13:31 +0000 (-0400) Subject: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14434 X-Git-Tag: 7.0.8-43~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=487973a4ad7aa79399be7d9e89760f8d665d6c92;p=imagemagick https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14434 --- diff --git a/coders/ps.c b/coders/ps.c index f5dcde5b1..15a4bb612 100644 --- a/coders/ps.c +++ b/coders/ps.c @@ -128,16 +128,16 @@ static int MagickDLLCall PostscriptDelegateMessage(void *handle, offset=0; messages=(char **) handle; if (*messages == (char *) NULL) - *messages=(char *) AcquireQuantumMemory(length+1,sizeof(char *)); + *messages=(char *) AcquireQuantumMemory((size_t) length+1,sizeof(char *)); else { - offset=strlen(*messages); - *messages=(char *) ResizeQuantumMemory(*messages,offset+length+1, + offset=(ssize_t) strlen(*messages); + *messages=(char *) ResizeQuantumMemory(*messages,(size_t) offset+length+1, sizeof(char *)); } if (*messages == (char *) NULL) return(0); - (void) memcpy(*messages+offset,message,length); + (void) memcpy(*messages+offset,message,(size_t) length); (*messages)[length+offset] ='\0'; return(length); } @@ -224,7 +224,7 @@ static MagickBooleanType InvokePostscriptDelegate( #endif if (ghost_info == (GhostInfo *) NULL) ExecuteGhostscriptCommand(command,status); - if ((ghost_info->revision)(&revision,sizeof(revision)) != 0) + if ((ghost_info->revision)(&revision,(int) sizeof(revision)) != 0) revision.revision=0; if (verbose != MagickFalse) { @@ -713,9 +713,9 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception) if (i == (ssize_t) priority) continue; hires_bounds=bounds; - priority=(size_t) i; + priority=i; } - if ((fabs(hires_bounds.x2-hires_bounds.x1) >= MagickEpsilon) && + if ((fabs(hires_bounds.x2-hires_bounds.x1) >= MagickEpsilon) && (fabs(hires_bounds.y2-hires_bounds.y1) >= MagickEpsilon)) { /* @@ -1634,13 +1634,14 @@ static MagickBooleanType WritePSImage(const ImageInfo *image_info,Image *image, else if ((image->gravity != UndefinedGravity) && (LocaleCompare(image_info->magick,"PS") == 0)) - (void) CopyMagickString(page_geometry,PSPageGeometry,MagickPathExtent); + (void) CopyMagickString(page_geometry,PSPageGeometry, + MagickPathExtent); (void) ConcatenateMagickString(page_geometry,">",MagickPathExtent); (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y, &geometry.width,&geometry.height); - scale.x=(double) (geometry.width*delta.x)/resolution.x; + scale.x=PerceptibleReciprocal(resolution.x)*geometry.width*delta.x; geometry.width=(size_t) floor(scale.x+0.5); - scale.y=(double) (geometry.height*delta.y)/resolution.y; + scale.y=PerceptibleReciprocal(resolution.y)*geometry.height*delta.y; geometry.height=(size_t) floor(scale.y+0.5); (void) ParseAbsoluteGeometry(page_geometry,&media_info); (void) ParseGravityGeometry(image,page_geometry,&page_info,exception); @@ -1914,7 +1915,7 @@ RestoreMSCWarning } (void) memset(&pixel,0,sizeof(pixel)); pixel.alpha=(MagickRealType) TransparentAlpha; - index=0; + index=(Quantum) 0; x=0; if ((image_info->type != TrueColorType) && (SetImageGray(image,exception) != MagickFalse)) diff --git a/coders/ps2.c b/coders/ps2.c index 206eb4fcb..1ed77e348 100644 --- a/coders/ps2.c +++ b/coders/ps2.c @@ -533,13 +533,14 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image, else if ((image->gravity != UndefinedGravity) && (LocaleCompare(image_info->magick,"PS") == 0)) - (void) CopyMagickString(page_geometry,PSPageGeometry,MagickPathExtent); + (void) CopyMagickString(page_geometry,PSPageGeometry, + MagickPathExtent); (void) ConcatenateMagickString(page_geometry,">",MagickPathExtent); (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y, &geometry.width,&geometry.height); - scale.x=(double) (geometry.width*delta.x)/resolution.x; + scale.x=PerceptibleReciprocal(resolution.x)*geometry.width*delta.x; geometry.width=(size_t) floor(scale.x+0.5); - scale.y=(double) (geometry.height*delta.y)/resolution.y; + scale.y=PerceptibleReciprocal(resolution.y)*geometry.height*delta.y; geometry.height=(size_t) floor(scale.y+0.5); (void) ParseAbsoluteGeometry(page_geometry,&media_info); (void) ParseGravityGeometry(image,page_geometry,&page_info,exception); diff --git a/coders/ps3.c b/coders/ps3.c index 6c5721d52..ab02db21b 100644 --- a/coders/ps3.c +++ b/coders/ps3.c @@ -963,8 +963,8 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image, } if (image->units == PixelsPerCentimeterResolution) { - resolution.x=(size_t) ((100.0*2.54*resolution.x+0.5)/100.0); - resolution.y=(size_t) ((100.0*2.54*resolution.y+0.5)/100.0); + resolution.x=(100.0*2.54*resolution.x+0.5)/100.0; + resolution.y=(100.0*2.54*resolution.y+0.5)/100.0; } SetGeometry(image,&geometry); (void) FormatLocaleString(page_geometry,MagickPathExtent,"%.20gx%.20g", @@ -979,13 +979,14 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image, else if ((image->gravity != UndefinedGravity) && (LocaleCompare(image_info->magick,"PS") == 0)) - (void) CopyMagickString(page_geometry,PSPageGeometry,MagickPathExtent); + (void) CopyMagickString(page_geometry,PSPageGeometry, + MagickPathExtent); (void) ConcatenateMagickString(page_geometry,">",MagickPathExtent); (void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y, &geometry.width,&geometry.height); - scale.x=(double) (geometry.width*delta.x)/resolution.x; + scale.x=PerceptibleReciprocal(resolution.x)*geometry.width*delta.x; geometry.width=(size_t) floor(scale.x+0.5); - scale.y=(double) (geometry.height*delta.y)/resolution.y; + scale.y=PerceptibleReciprocal(resolution.y)*geometry.height*delta.y; geometry.height=(size_t) floor(scale.y+0.5); (void) ParseAbsoluteGeometry(page_geometry,&media_info); (void) ParseGravityGeometry(image,page_geometry,&page_info,exception);