File GraphicsMagick-CVE-2017-11637.patch of Package GraphicsMagick.9388

Index: GraphicsMagick-1.3.25/coders/pcl.c
===================================================================
--- GraphicsMagick-1.3.25.orig/coders/pcl.c	2013-12-31 20:55:53.000000000 +0100
+++ GraphicsMagick-1.3.25/coders/pcl.c	2018-02-16 15:18:53.975617669 +0100
@@ -1010,7 +1010,16 @@ static unsigned int WritePCLImage(const
               for (x=0; x < (long) image->columns; x++)
                 {
                   byte<<=1;
-                  if (indexes[x] == blk_ind) byte |= 1;
+                  if (image->storage_class == PseudoClass)
+                    {
+                      if (indexes[x] == blk_ind)
+                        byte |= 1;
+                    }
+                  else
+                    {
+                      if (p[x].red == 0)
+                        byte |= 1;
+                    }
                   bit++;
                   if (bit == 8)
                     {
@@ -1028,10 +1037,20 @@ static unsigned int WritePCLImage(const
               /*
                 8 bit PseudoClass row
               */
-              indexes=AccessImmutableIndexes(image);
-              for (x=0; x < (long) image->columns; x++)
+              if (image->storage_class == PseudoClass)
                 {
-                  *q++=indexes[x];
+                  indexes=AccessImmutableIndexes(image);
+                  for (x=0; x < (long) image->columns; x++)
+                    {
+                      *q++=indexes[x];
+                    }
+                }
+              else
+                {
+                  for (x=0; x < (long) image->columns; x++)
+                    {
+                      *q++=PixelIntensityRec601(&p[x]);
+                    }
                 }
             }
           else
openSUSE Build Service is sponsored by