File GraphicsMagick-CVE-2017-11638,11642.patch of Package GraphicsMagick.9388

--- a/coders/map.c	Sat Jul 22 15:40:00 2017 -0500
+++ b/coders/map.c	Sat Jul 22 16:29:35 2017 -0500
@@ -349,16 +349,17 @@
   /*
     Allocate colormap.
   */
-  if (!IsPaletteImage(image,&image->exception))
-    (void) SetImageType(image,PaletteType);
+  if (SetImageType(image,PaletteType) == MagickFail)
+    ThrowMAPWriterException(ResourceLimitError,MemoryAllocationFailed,image);
   packet_size=image->depth > 8 ? 2 : 1;
-  pixels=MagickAllocateMemory(unsigned char *,image->columns*packet_size);
+  pixels=MagickAllocateArray(unsigned char *,image->columns,packet_size);
   if (pixels == (unsigned char *) NULL)
     ThrowMAPWriterException(ResourceLimitError,MemoryAllocationFailed,image);
   packet_size=image->colors > 256 ? 6 : 3;
-  colormap=MagickAllocateMemory(unsigned char *,packet_size*image->colors);
+  colormap=MagickAllocateArray(unsigned char *,packet_size,image->colors);
   if (colormap == (unsigned char *) NULL)
     ThrowMAPWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+
   /*
     Write colormap to file.
   */


openSUSE Build Service is sponsored by