File GraphicsMagick-CVE-2014-9819.patch of Package GraphicsMagick.6323

Index: GraphicsMagick-1.3.21/coders/palm.c
===================================================================
--- GraphicsMagick-1.3.21.orig/coders/palm.c	2015-02-28 21:51:58.000000000 +0100
+++ GraphicsMagick-1.3.21/coders/palm.c	2016-08-04 22:37:16.397787628 +0200
@@ -542,7 +542,7 @@ void LogPALMHeader(const PalmHeader* pal
 %
 %
 */
-static int FindColor(PixelPacket *pixel)
+static long FindColor(PixelPacket *pixel)
 {
   register long
     i;
@@ -748,7 +748,7 @@ static Image *ReadPALMImage(const ImageI
           for (i = 0; i < count; i++)
             {
               (void) ReadBlobByte(image);
-              index=255 - i;
+              index=(unsigned int)(255 - i);
               VerifyColormapIndex(image,index);
               image->colormap[index].red = ScaleCharToQuantum(ReadBlobByte(image));
               image->colormap[index].green = ScaleCharToQuantum(ReadBlobByte(image));
@@ -759,7 +759,7 @@ static Image *ReadPALMImage(const ImageI
         }
       for (; i < (1U << palm_header.bits_per_pixel); i++)
         {
-          index=255 - i;
+          index=(unsigned int)(255 - i);
           VerifyColormapIndex(image,index);
           image->colormap[index].red = ScaleCharToQuantum(PalmPalette[i][0]);
           image->colormap[index].green = ScaleCharToQuantum(PalmPalette[i][1]);
@@ -817,7 +817,7 @@ static Image *ReadPALMImage(const ImageI
   if (palm_header.compression_type == PALM_COMPRESSION_SCANLINE)
     lastrow = MagickAllocateMemory(unsigned char *,Max(palm_header.bytes_per_row,2*image->columns));
 
-  mask = (1l << palm_header.bits_per_pixel) - 1;
+  mask = (unsigned long)(1l << palm_header.bits_per_pixel) - 1;
 
   for (y = 0; y < (long) image->rows; y++)
     {
@@ -1089,7 +1089,7 @@ OptimizePALMImage(const ImageInfo *image
 #endif
 static unsigned int WritePALMImage(const ImageInfo *image_info,Image *image)
 {
-  int
+  long
     y;
 
   QuantizeInfo
@@ -1321,7 +1321,7 @@ static unsigned int WritePALMImage(const
     ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
 
   ClearPixelPacket(&transpix);
-  for (y=0; y < (int) image->rows; y++)
+  for (y=0; y < (long) image->rows; y++)
     {
       ptr = one_row;
       (void) memset(ptr, 0, bytes_per_row);
@@ -1331,7 +1331,7 @@ static unsigned int WritePALMImage(const
       indexes=AccessMutableIndexes(image);
       if (bits_per_pixel == 16)
         {
-          for (x=0; x < (int) image->columns; x++)
+          for (x=0; x < (long) image->columns; x++)
             {
               color16 = (unsigned short) (((p->red * 31) / MaxRGB) << 11
                                           | ((p->green * 63) / MaxRGB) << 5
@@ -1353,7 +1353,7 @@ static unsigned int WritePALMImage(const
         {
           byte = 0x00;
           bit = (unsigned char) (8 - bits_per_pixel);
-          for (x=0; x < (int) image->columns; x++)
+          for (x=0; x < (long) image->columns; x++)
             {
               if (bits_per_pixel < 8) /* Make sure we use the entire colorspace for bits_per_pixel */
                 color = (unsigned char) (indexes[x] * ((1 << bits_per_pixel) - 1) /
openSUSE Build Service is sponsored by