File ImageMagick-CVE-2020-27759,27769,27754.patch of Package ImageMagick.17344
Index: ImageMagick-7.0.7-34/MagickCore/quantize.c
===================================================================
--- ImageMagick-7.0.7-34.orig/MagickCore/quantize.c 2020-12-07 12:50:42.832193159 +0100
+++ ImageMagick-7.0.7-34/MagickCore/quantize.c 2020-12-07 12:51:34.152524143 +0100
@@ -2340,8 +2340,8 @@ MagickExport MagickBooleanType Posterize
const DitherMethod dither_method,ExceptionInfo *exception)
{
#define PosterizeImageTag "Posterize/Image"
-#define PosterizePixel(pixel) (Quantum) (QuantumRange*(MagickRound( \
- QuantumScale*pixel*(levels-1)))/MagickMax((ssize_t) levels-1,1))
+#define PosterizePixel(pixel) ClampToQuantum((MagickRealType) QuantumRange*( \
+ MagickRound(QuantumScale*pixel*(levels-1)))/MagickMax((ssize_t) levels-1,1))
CacheView
*image_view;
@@ -3285,6 +3285,10 @@ static int IntensityCompare(const void *
color_2=(PixelInfo *) y;
intensity=GetPixelInfoIntensity((const Image *) NULL,color_1)-
GetPixelInfoIntensity((const Image *) NULL,color_2);
+ if (intensity < (double) INT_MIN)
+ intensity=(double) INT_MIN;
+ if (intensity > (double) INT_MAX)
+ intensity=(double) INT_MAX;
return((int) intensity);
}