File ImageMagick-CVE-2020-27753.patch of Package ImageMagick.23974

Index: ImageMagick-6.8.8-1/coders/miff.c
===================================================================
--- ImageMagick-6.8.8-1.orig/coders/miff.c	2020-12-09 19:31:55.979391974 +0100
+++ ImageMagick-6.8.8-1/coders/miff.c	2020-12-09 19:42:37.395895369 +0100
@@ -213,6 +213,7 @@ static void PushRunlengthPacket(Image *i
       switch (image->depth)
       {
         case 32:
+        default:
         {
           *index=ConstrainColormapIndex(image,
             (*p << 24) | (*(p+1) << 16) | (*(p+2) << 8) | *(p+3));
@@ -231,9 +232,6 @@ static void PushRunlengthPacket(Image *i
           p++;
           break;
         }
-        default:
-          (void) ThrowMagickException(&image->exception,GetMagickModule(),
-            CorruptImageError,"ImageDepthNotSupported","`%s'",image->filename);
       }
       *pixel=image->colormap[(ssize_t) *index];
       switch (image->depth)
@@ -264,6 +262,7 @@ static void PushRunlengthPacket(Image *i
           break;
         }
         case 32:
+        default:
         {
           unsigned int
             quantum;
@@ -276,9 +275,6 @@ static void PushRunlengthPacket(Image *i
             }
           break;
         }
-        default:
-          (void) ThrowMagickException(&image->exception,GetMagickModule(),
-            CorruptImageError,"ImageDepthNotSupported","`%s'",image->filename);
       }
       *length=(size_t) (*p++)+1;
       return;
@@ -346,6 +342,7 @@ static void PushRunlengthPacket(Image *i
       break;
     }
     case 32:
+    default:
     {
       unsigned int
         quantum;
@@ -377,9 +374,6 @@ static void PushRunlengthPacket(Image *i
         }
       break;
     }
-    default:
-      (void) ThrowMagickException(&image->exception,GetMagickModule(),
-        CorruptImageError,"ImageDepthNotSupported","`%s'",image->filename);
   }
   *length=(size_t) (*p++)+1;
 }
@@ -1098,7 +1092,8 @@ static Image *ReadMIFFImage(const ImageI
     */
     if ((LocaleCompare(id,"ImageMagick") != 0) ||
         (image->storage_class == UndefinedClass) ||
-        (image->columns == 0) || (image->rows == 0))
+        (image->columns == 0) || (image->rows == 0) ||
+        (image->depth == 0) || (image->depth > 64))
       {
         if (image->previous == (Image *) NULL)
           ThrowReaderException(CorruptImageError,"ImproperImageHeader");
@@ -1199,9 +1194,6 @@ static Image *ReadMIFFImage(const ImageI
             p=colormap;
             switch (image->depth)
             {
-              default:
-                ThrowReaderException(CorruptImageError,
-                  "ImageDepthNotSupported");
               case 8:
               {
                 unsigned char
@@ -1235,6 +1227,7 @@ static Image *ReadMIFFImage(const ImageI
                 break;
               }
               case 32:
+              default:
               {
                 unsigned int
                   pixel;
@@ -1755,6 +1748,7 @@ static unsigned char *PopRunlengthPacket
     {
       switch (image->depth)
       {
+        default:
         case 32:
         {
           *pixels++=(unsigned char) ((size_t) index >> 24);
@@ -1767,13 +1761,11 @@ static unsigned char *PopRunlengthPacket
           *pixels++=(unsigned char) index;
           break;
         }
-        default:
-          (void) ThrowMagickException(&image->exception,GetMagickModule(),
-            CorruptImageError,"ImageDepthNotSupported","`%s'",image->filename);
       }
       switch (image->depth)
       {
         case 32:
+        default:
         {
           unsigned int
             value;
@@ -1809,9 +1801,6 @@ static unsigned char *PopRunlengthPacket
             }
           break;
         }
-        default:
-          (void) ThrowMagickException(&image->exception,GetMagickModule(),
-            CorruptImageError,"ImageDepthNotSupported","`%s'",image->filename);
       }
       *pixels++=(unsigned char) length;
       return(pixels);
@@ -1819,6 +1808,7 @@ static unsigned char *PopRunlengthPacket
   switch (image->depth)
   {
     case 32:
+    default:
     {
       unsigned int
         value;
@@ -1896,9 +1886,6 @@ static unsigned char *PopRunlengthPacket
         }
       break;
     }
-    default:
-      (void) ThrowMagickException(&image->exception,GetMagickModule(),
-        CorruptImageError,"ImageDepthNotSupported","`%s'",image->filename);
   }
   *pixels++=(unsigned char) length;
   return(pixels);
@@ -1990,8 +1977,7 @@ static MagickBooleanType WriteMIFFImage(
     if ((image->storage_class == PseudoClass) &&
         (image->colors > (size_t) (GetQuantumRange(image->depth)+1)))
       (void) SetImageStorageClass(image,DirectClass);
-    image->depth=image->depth <= 8 ? 8UL : image->depth <= 16 ? 16UL :
-      image->depth <= 32 ? 32UL : 64UL;
+    image->depth=image->depth <= 8 ? 8UL : image->depth <= 16 ? 16UL : 32UL;
     if (IsGrayImage(image,&image->exception) == MagickFalse)
       {
         /*
@@ -2353,12 +2339,8 @@ static MagickBooleanType WriteMIFFImage(
         {
           switch (quantum_info->depth)
           {
-            default:
-            {
-              colormap=(unsigned char *) RelinquishMagickMemory(colormap);
-              ThrowWriterException(CorruptImageError,"ImageDepthNotSupported");
-            }
             case 32:
+            default:
             {
               register unsigned int
                 pixel;
openSUSE Build Service is sponsored by