File ImageMagick-CVE-2017-16545.patch of Package ImageMagick.8212

# HG changeset patch
# User Bob Friesenhahn <bfriesen@GraphicsMagick.org>
# Date 1509823001 18000
# Node ID e8086faa52d0b2ce6d9a8bc81b19d22fc837579a
# Parent  fb5c791e57068b2ed75a397cb3ba8b80b8722ab6
WPG: Assure that colormapped image is a PseudoClass type with valid colormapped indexes.

Index: ImageMagick-6.8.8-1/coders/wpg.c
===================================================================
--- ImageMagick-6.8.8-1.orig/coders/wpg.c	2017-11-22 15:01:29.512826608 +0100
+++ ImageMagick-6.8.8-1/coders/wpg.c	2017-11-22 15:01:29.520826746 +0100
@@ -477,7 +477,13 @@ static int UnpackWPGRaster(Image *image,
 
   while(y<(ssize_t) image->rows)
     {
-      bbuf=ReadBlobByte(image);
+      i = ReadBlobByte(image);
+          if(i==EOF)
+            {
+          RelinquishMagickMemory(BImgBuff);
+          return(-5);
+        }
+      bbuf = i;
 
       RunCount=bbuf & 0x7F;
       if(bbuf & 0x80)
@@ -1306,7 +1312,7 @@ static Image *ReadWPGImage(const ImageIn
               if (status == MagickFalse)
                 break;
 
-              if ((image->colors == 0) && (bpp != 24))
+              if ((image->storage_class != PseudoClass) && (bpp != 24))
                 {
                   size_t
                     one;