(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sun, 15 Feb 2015 13:22:11 +0000 (13:22 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sun, 15 Feb 2015 13:22:11 +0000 (13:22 +0000)
coders/palm.c

index f95ae8cb6b50989d6fd0f486d233e92e079590ac..075fd5dc910f660c5926eeb8cad160b995017911 100644 (file)
@@ -255,10 +255,6 @@ static Image *ReadPALMImage(const ImageInfo *image_info,
   register Quantum
     *q;
 
-  ssize_t
-    count,
-    y;
-
   size_t
     bytes_per_row,
     flags,
@@ -277,6 +273,10 @@ static Image *ReadPALMImage(const ImageInfo *image_info,
     size,
     bit;
 
+  ssize_t
+    count,
+    y;
+
   unsigned char
     *lastrow,
     *one_row,
@@ -317,13 +317,19 @@ static Image *ReadPALMImage(const ImageInfo *image_info,
     bytes_per_row=ReadBlobMSBShort(image);
     flags=ReadBlobMSBShort(image);
     bits_per_pixel=(size_t) ReadBlobByte(image);
-    if ((bits_per_pixel == 0) || (bits_per_pixel > 16))
-      ThrowReaderException(CorruptImageError,"ImproperImageHeader");
+    if ((bits_per_pixel != 1) && (bits_per_pixel != 2) &&
+        (bits_per_pixel != 4) && (bits_per_pixel != 8) &&
+        (bits_per_pixel != 16))
+      ThrowReaderException(CorruptImageError,"UnrecognizedBitsPerPixel");
     version=(size_t) ReadBlobByte(image);
     (void) version;
     nextDepthOffset=(size_t) ReadBlobMSBShort(image);
     transparentIndex=(size_t) ReadBlobByte(image);
     compressionType=(size_t) ReadBlobByte(image);
+    if ((compressionType != PALM_COMPRESSION_NONE) &&
+        (compressionType != PALM_COMPRESSION_SCANLINE ) &&
+        (compressionType != PALM_COMPRESSION_RLE))
+      ThrowReaderException(CorruptImageError,"UnrecognizedImageCompression");
     pad=ReadBlobMSBShort(image);
     (void) pad;
     /*
@@ -391,6 +397,14 @@ static Image *ReadPALMImage(const ImageInfo *image_info,
         image->storage_class=PseudoClass;
         image->depth=8;
       }
+    if (image_info->ping != MagickFalse)
+      {
+        (void) CloseBlob(image);
+        return(image);
+      }
+    status=SetImageExtent(image,image->columns,image->rows);
+    if (status == MagickFalse)
+      return(DestroyImageList(image));
     one_row=(unsigned char *) AcquireQuantumMemory(MagickMax(bytes_per_row,
       2*image->columns),sizeof(*one_row));
     if (one_row == (unsigned char *) NULL)
@@ -965,10 +979,8 @@ static MagickBooleanType WritePALMImage(const ImageInfo *image_info,
     if (GetNextImageInList(image) == (Image *) NULL)
       break;
     /* padding to 4 byte word */
-    for (cc = (GetBlobSize(image))%4; cc > 0; cc--)
-    {
+    for (cc=(GetBlobSize(image)) % 4; cc > 0; cc--)
       (void) WriteBlobByte(image,0);
-    } 
     /* write nextDepthOffset and return to end of image */
     offset=SeekBlob(image,currentOffset+10,SEEK_SET);
     nextDepthOffset=(size_t) ((GetBlobSize(image)-currentOffset)/4);