]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <mikayla-grace@urban-warrior.org>
Sun, 10 Feb 2019 00:36:29 +0000 (19:36 -0500)
committerCristy <mikayla-grace@urban-warrior.org>
Sun, 10 Feb 2019 00:36:29 +0000 (19:36 -0500)
coders/pict.c

index 03f70f901a6d1d2dd0cf87a0bc1f2b6e8ad97c64..28050f41fccd0a6f6a3a35cab1fdb6b139d5a1ac 100644 (file)
@@ -325,14 +325,16 @@ static MagickBooleanType
 %
 */
 
-static unsigned char *ExpandBuffer(unsigned char *pixels,
-  MagickSizeType *bytes_per_line,const unsigned int bits_per_pixel)
+static const unsigned char *ExpandBuffer(const unsigned char *restrict pixels,
+  const unsigned int bits_per_pixel,MagickSizeType *bytes_per_line)
 {
+  register const unsigned char
+    *p;
+
   register ssize_t
     i;
 
   register unsigned char
-    *p,
     *q;
 
   static unsigned char
@@ -402,11 +404,13 @@ static unsigned char *DecodeImage(Image *blob,Image *image,
   MagickSizeType
     number_pixels;
 
+  register const unsigned char
+    *p;
+
   register ssize_t
     i;
 
   register unsigned char
-    *p,
     *q;
 
   size_t
@@ -478,7 +482,7 @@ static unsigned char *DecodeImage(Image *blob,Image *image,
             status=MagickFalse;
             break;
           }
-        p=ExpandBuffer(scanline,&number_pixels,bits_per_pixel);
+        p=ExpandBuffer(scanline,bits_per_pixel,&number_pixels);
         if ((q+number_pixels) > (pixels+(*extent)))
           {
             status=MagickFalse;
@@ -517,7 +521,7 @@ static unsigned char *DecodeImage(Image *blob,Image *image,
         {
           length=(size_t) ((scanline[j] & 0xff)+1);
           number_pixels=length*bytes_per_pixel;
-          p=ExpandBuffer(scanline+j+1,&number_pixels,bits_per_pixel);
+          p=ExpandBuffer(scanline+j+1,bits_per_pixel,&number_pixels);
           if ((q-pixels+number_pixels) <= *extent)
             (void) memcpy(q,p,(size_t) number_pixels);
           q+=number_pixels;
@@ -527,7 +531,7 @@ static unsigned char *DecodeImage(Image *blob,Image *image,
         {
           length=(size_t) (((scanline[j] ^ 0xff) & 0xff)+2);
           number_pixels=bytes_per_pixel;
-          p=ExpandBuffer(scanline+j+1,&number_pixels,bits_per_pixel);
+          p=ExpandBuffer(scanline+j+1,bits_per_pixel,&number_pixels);
           for (i=0; i < (ssize_t) length; i++)
           {
             if ((q-pixels+number_pixels) <= *extent)
@@ -982,7 +986,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
               Clipping rectangle.
             */
             length=ReadBlobMSBShort(image);
-            if (length > GetBlobSize(image))
+            if ((MagickSizeType) length > GetBlobSize(image))
               ThrowPICTException(CorruptImageError,
                 "InsufficientImageDataInFile");
             if (length != 0x000a)
@@ -1033,7 +1037,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
             if (pattern != 1)
               ThrowPICTException(CorruptImageError,"UnknownPatternType");
             length=ReadBlobMSBShort(image);
-            if (length > GetBlobSize(image))
+            if ((MagickSizeType) length > GetBlobSize(image))
               ThrowPICTException(CorruptImageError,
                 "InsufficientImageDataInFile");
             if (ReadRectangle(image,&frame) == MagickFalse)
@@ -1047,7 +1051,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
             (void) ReadBlobMSBLong(image);
             flags=(ssize_t) ReadBlobMSBShort(image);
             length=ReadBlobMSBShort(image);
-            if (length > GetBlobSize(image))
+            if ((MagickSizeType) length > GetBlobSize(image))
               ThrowPICTException(CorruptImageError,
                 "InsufficientImageDataInFile");
             for (i=0; i <= (ssize_t) length; i++)
@@ -1110,7 +1114,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
               Skip polygon or region.
             */
             length=ReadBlobMSBShort(image);
-            if (length > GetBlobSize(image))
+            if ((MagickSizeType) length > GetBlobSize(image))
               ThrowPICTException(CorruptImageError,
                 "InsufficientImageDataInFile");
             for (i=0; i < (ssize_t) (length-2); i++)
@@ -1235,7 +1239,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
                   Skip region.
                 */
                 length=ReadBlobMSBShort(image);
-                if (length > GetBlobSize(image))
+                if ((MagickSizeType) length > GetBlobSize(image))
                   ThrowPICTException(CorruptImageError,
                     "InsufficientImageDataInFile");
                 for (i=0; i < (ssize_t) (length-2); i++)
@@ -1360,7 +1364,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
             */
             type=ReadBlobMSBShort(image);
             length=ReadBlobMSBShort(image);
-            if (length > GetBlobSize(image))
+            if ((MagickSizeType) length > GetBlobSize(image))
               ThrowPICTException(CorruptImageError,
                 "InsufficientImageDataInFile");
             if (length == 0)
@@ -1472,7 +1476,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
             ThrowPICTException(FileOpenError,"UnableToCreateTemporaryFile");
           }
         length=ReadBlobMSBLong(image);
-        if (length > GetBlobSize(image))
+        if ((MagickSizeType) length > GetBlobSize(image))
           ThrowPICTException(CorruptImageError,
             "InsufficientImageDataInFile");
         if (length > 154)
@@ -1526,7 +1530,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
           Skip reserved.
         */
         length=ReadBlobMSBShort(image);
-        if (length > GetBlobSize(image))
+        if ((MagickSizeType) length > GetBlobSize(image))
           ThrowPICTException(CorruptImageError,
             "InsufficientImageDataInFile");
         for (i=0; i < (ssize_t) length; i++)
@@ -1540,7 +1544,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
           Skip reserved.
         */
         length=(size_t) ((code >> 7) & 0xff);
-        if (length > GetBlobSize(image))
+        if ((MagickSizeType) length > GetBlobSize(image))
           ThrowPICTException(CorruptImageError,
             "InsufficientImageDataInFile");
         for (i=0; i < (ssize_t) length; i++)
@@ -1928,7 +1932,7 @@ static MagickBooleanType WritePICTImage(const ImageInfo *image_info,
       (void) WriteBlobMSBShort(image,0x0000);
       (void) WriteBlobMSBShort(image,(unsigned short) y_resolution);
       (void) WriteBlobMSBShort(image,0x0000);
-      (void) WriteBlobMSBLong(image,length);
+      (void) WriteBlobMSBLong(image,(unsigned int) length);
       (void) WriteBlobMSBShort(image,0x0001);
       (void) WriteBlobMSBLong(image,0x0B466F74U);
       (void) WriteBlobMSBLong(image,0x6F202D20U);