File ImageMagick-CVE-2016-5691.patch of Package ImageMagick.8212

Index: ImageMagick-6.8.9-8/coders/dcm.c
===================================================================
--- ImageMagick-6.8.9-8.orig/coders/dcm.c	2016-06-22 15:14:27.322581300 +0200
+++ ImageMagick-6.8.9-8/coders/dcm.c	2016-06-22 15:14:27.526584551 +0200
@@ -3935,9 +3935,12 @@ static Image *ReadDCMImage(const ImageIn
                 pixel.blue&=mask;
                 if (scale != (Quantum *) NULL)
                   {
-                    pixel.red=scale[pixel.red];
-                    pixel.green=scale[pixel.green];
-                    pixel.blue=scale[pixel.blue];
+                    if (pixel.red <= GetQuantumRange(depth))
+                      pixel.red=scale[pixel.red];
+                    if (pixel.green <= GetQuantumRange(depth))
+                      pixel.green=scale[pixel.green];
+                    if (pixel.blue <= GetQuantumRange(depth))
+                      pixel.blue=scale[pixel.blue];
                   }
               }
             SetPixelRed(q,pixel.red);