File ImageMagick-CVE-2020-27758.patch of Package ImageMagick.19146

Index: ImageMagick-7.0.7-34/coders/txt.c
===================================================================
--- ImageMagick-7.0.7-34.orig/coders/txt.c	2018-05-20 17:55:43.000000000 +0200
+++ ImageMagick-7.0.7-34/coders/txt.c	2020-12-08 17:29:23.419461082 +0100
@@ -561,16 +561,16 @@ static Image *ReadTXTImage(const ImageIn
             green+=(range+1)/2.0;
             blue+=(range+1)/2.0;
           }
-        pixel.red=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (red+0.5),
-          range);
-        pixel.green=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (green+0.5),
-          range);
-        pixel.blue=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (blue+0.5),
-          range);
-        pixel.black=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (black+0.5),
-          range);
-        pixel.alpha=(MagickRealType) ScaleAnyToQuantum((QuantumAny) (alpha+0.5),
-          range);
+        pixel.red=(MagickRealType) ScaleAnyToQuantum((QuantumAny)
+          MagickMax(red+0.5,0.0),range);
+        pixel.green=(MagickRealType) ScaleAnyToQuantum((QuantumAny)
+          MagickMax(green+0.5,0.0),range);
+        pixel.blue=(MagickRealType) ScaleAnyToQuantum((QuantumAny)
+          MagickMax(blue+0.5,0.0),range);
+        pixel.black=(MagickRealType) ScaleAnyToQuantum((QuantumAny)
+          MagickMax(black+0.5,0.0),range);
+        pixel.alpha=(MagickRealType) ScaleAnyToQuantum((QuantumAny)
+          MagickMax(alpha+0.5,0.0),range);
         q=GetAuthenticPixels(image,(ssize_t) x_offset,(ssize_t) y_offset,1,1,
           exception);
         if (q == (Quantum *) NULL)
openSUSE Build Service is sponsored by