]> granicus.if.org Git - imagemagick/commitdiff
The number of colors is limited to 65535
authorCristy <urban-warrior@imagemagick.org>
Fri, 6 May 2016 23:11:52 +0000 (19:11 -0400)
committerCristy <urban-warrior@imagemagick.org>
Fri, 6 May 2016 23:11:52 +0000 (19:11 -0400)
coders/xpm.c

index 6de6c0b345fcf82c1098291600a450d1f24f5873..7d9021c376e7225b7e0799f4dd27af92c3c27726 100644 (file)
@@ -336,9 +336,13 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception)
     if (count == 4)
       break;
   }
-  if ((count != 4) || (width == 0) || (width > 10) || (image->columns == 0) ||
-      (image->rows == 0) || (image->colors == 0))
-    ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+  if ((count != 4) || (width == 0) || (width > 2) ||
+      (image->columns == 0) || (image->rows == 0) ||
+      (image->colors == 0) || (image->colors > MaxColormapSize))
+    {
+      xpm_buffer=DestroyString(xpm_buffer);
+      ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+    }
   /*
     Remove unquoted characters.
   */