]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Thu, 16 Sep 2010 22:59:09 +0000 (22:59 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Thu, 16 Sep 2010 22:59:09 +0000 (22:59 +0000)
13 files changed:
coders/bgr.c
coders/cmyk.c
coders/gray.c
coders/mono.c
coders/pes.c
coders/psd.c
coders/raw.c
coders/rgb.c
coders/uyvy.c
coders/wbmp.c
coders/xcf.c
coders/ycbcr.c
coders/yuv.c

index ed9b7ec7f44a34bea4590308934f9aad82d7115c..5a5b7b1e247219aebd91b7c7fa781f5b2737a853 100644 (file)
@@ -149,13 +149,9 @@ static Image *ReadBGRImage(const ImageInfo *image_info,
           image=DestroyImageList(image);
           return((Image *) NULL);
         }
-      for (i=0; i < image->offset; i++)
-        if (ReadBlobByte(image) == EOF)
-          {
-            ThrowFileException(exception,CorruptImageError,
-              "UnexpectedEndOfFile",image->filename);
-            break;
-          }
+      if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+          image->filename);
     }
   /*
     Create virtual canvas to support cropping (i.e. image.rgb[100x100+10+20]).
@@ -629,13 +625,9 @@ static Image *ReadBGRImage(const ImageInfo *image_info,
             image=DestroyImageList(image);
             return((Image *) NULL);
           }
-        for (i=0; i < image->offset; i++)
-          if (ReadBlobByte(image) == EOF)
-            {
-              ThrowFileException(exception,CorruptImageError,
-                "UnexpectedEndOfFile",image->filename);
-              break;
-            }
+        if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+          ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+            image->filename);
         length=GetQuantumExtent(canvas_image,quantum_info,BlueQuantum);
         for (i=0; i < (ssize_t) scene; i++)
           for (y=0; y < (ssize_t) image->extract_info.height; y++)
index 31e223ff5dee583870b7441f1dd7c15d415f8265..69b31e09171e90d6eefbffeaa58e16901a4dd3d3 100644 (file)
@@ -149,13 +149,9 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           image=DestroyImageList(image);
           return((Image *) NULL);
         }
-      for (i=0; i < image->offset; i++)
-        if (ReadBlobByte(image) == EOF)
-          {
-            ThrowFileException(exception,CorruptImageError,
-              "UnexpectedEndOfFile",image->filename);
-            break;
-          }
+      if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+          image->filename);
     }
   /*
     Create virtual canvas to support cropping (i.e. image.cmyk[100x100+10+20]).
@@ -701,13 +697,9 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
             image=DestroyImageList(image);
             return((Image *) NULL);
           }
-        for (i=0; i < image->offset; i++)
-          if (ReadBlobByte(image) == EOF)
-            {
-              ThrowFileException(exception,CorruptImageError,
-                "UnexpectedEndOfFile",image->filename);
-              break;
-            }
+        if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+          ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+            image->filename);
         length=GetQuantumExtent(canvas_image,quantum_info,CyanQuantum);
         for (i=0; i < (ssize_t) scene; i++)
           for (y=0; y < (ssize_t) image->extract_info.height; y++)
index db60438c5eff1dc3295628ae5f1d99215cde837a..c24980c7659d2f89ea1b0443bfe29569a9b97e53 100644 (file)
@@ -148,13 +148,9 @@ static Image *ReadGRAYImage(const ImageInfo *image_info,
       image=DestroyImageList(image);
       return((Image *) NULL);
     }
-  for (i=0; i < image->offset; i++)
-    if (ReadBlobByte(image) == EOF)
-      {
-        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
-          image->filename);
-        break;
-      }
+  if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+    ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+      image->filename);
   /*
     Create virtual canvas to support cropping (i.e. image.gray[100x100+10+20]).
   */
index 71edd7f1fffae341bc5c434f37f4c6111d337a83..0915be9400e01c591b35a734258f5df82e50b9b2 100644 (file)
@@ -140,13 +140,9 @@ static Image *ReadMONOImage(const ImageInfo *image_info,
       image=DestroyImageList(image);
       return((Image *) NULL);
     }
-  for (i=0; i < image->offset; i++)
-    if (ReadBlobByte(image) == EOF)
-      {
-        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
-          image->filename);
-        break;
-      }
+  if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+    ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+      image->filename);
   /*
     Initialize image colormap.
   */
index 4a08c6c00b2c58ce98f9ed2a2bd2e21b05272b65..81c32b9f53dbac8e7bef303ee24c894d980b271c 100644 (file)
@@ -493,9 +493,9 @@ static Image *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception)
     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
   count=ReadBlob(image,4,version);
   offset=(int) ReadBlobLSBLong(image);
-  for (i=0; i < (offset+36); i++)
-    if (ReadBlobByte(image) == EOF)
-      break;
+  if (DiscardBlobBytes(image,offset+36) == MagickFalse)
+    ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+      image->filename);
   if (EOFBlob(image) != MagickFalse)
     ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile");
   /*
@@ -510,9 +510,9 @@ static Image *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception)
   }
   for ( ; i < 256L; i++)
     blocks[i].offset=0;
-  for (i=0; i < (ssize_t) (532L-number_colors-21); i++)
-    if (ReadBlobByte(image) == EOF)
-      break;
+  if (DiscardBlobBytes(image,532L-number_colors-21) == MagickFalse)
+    ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+      image->filename);
   if (EOFBlob(image) != MagickFalse)
     ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile");
   /*
index 28771092a4ce1c0cb77dabc42afac9f915df9852..2b8ea3c96919b8e42b18c931c3b5b2ed4ff60cfa 100644 (file)
@@ -932,9 +932,12 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception)
       length=ReadBlobMSBLong(image);
     }
   if ((image_info->number_scenes == 1) && (image_info->scene == 0))
-    if (DiscardBlobBytes(image,length) == MagickFalse)
-      ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
-        image->filename);
+    {
+      if (DiscardBlobBytes(image,length) == MagickFalse)
+        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+          image->filename);
+      length=0;
+    }
   if (length == 0)
     {
       if (image->debug != MagickFalse)
@@ -1065,19 +1068,15 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception)
                     if (image->debug != MagickFalse)
                       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                         "      layer mask: offset(%.20g,%.20g), size(%.20g,%.20g), length=%.20g",
-                        (double) layer_info[i].mask.x,
-                        (double) layer_info[i].mask.y,
+                        (double) layer_info[i].mask.x,(double) layer_info[i].mask.y,
                         (double) layer_info[i].mask.width,(double)
                         layer_info[i].mask.height,(double) length-16);
                     /*
                       Skip over the rest of the layer mask information.
                     */
                     if (DiscardBlobBytes(image,length-16) == MagickFalse)
-                      {
-                        ThrowFileException(exception,CorruptImageError,
-                          "UnexpectedEndOfFile",image->filename);
-                        break;
-                      }
+                      ThrowFileException(exception,CorruptImageError,
+                        "UnexpectedEndOfFile",image->filename);
                   }
                 combinedlength+=length+4;  /* +4 for length */
                 length=ReadBlobMSBLong(image);
@@ -1160,11 +1159,8 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception)
                     "      unsupported data: length=%.20g",(double)
                     (size-combinedlength));
                 if (DiscardBlobBytes(image,size-combinedlength) == MagickFalse)
-                  {
-                    ThrowFileException(exception,CorruptImageError,
-                      "UnexpectedEndOfFile",image->filename);
-                    break;
-                  }
+                  ThrowFileException(exception,CorruptImageError,
+                    "UnexpectedEndOfFile",image->filename);
               }
             /*
               Allocate layered image.
index 7f59eef00557a360ba4f842a2e87b72b096cfd30..b834aba9cdbb1c8241fe4aa1cdb08a2756189f32 100644 (file)
@@ -146,13 +146,9 @@ static Image *ReadRAWImage(const ImageInfo *image_info,
       image=DestroyImageList(image);
       return((Image *) NULL);
     }
-  for (i=0; i < image->offset; i++)
-    if (ReadBlobByte(image) == EOF)
-      {
-        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
-          image->filename);
-        break;
-      }
+  if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+    ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+      image->filename);
   /*
     Create virtual canvas to support cropping (i.e. image.gray[100x100+10+20]).
   */
index 252b3ca2d204602929e1c526a3224a1370edf0d5..0ec26f2b1283bd4bc34bfeea74b4432f89551fa8 100644 (file)
@@ -149,13 +149,9 @@ static Image *ReadRGBImage(const ImageInfo *image_info,
           image=DestroyImageList(image);
           return((Image *) NULL);
         }
-      for (i=0; i < image->offset; i++)
-        if (ReadBlobByte(image) == EOF)
-          {
-            ThrowFileException(exception,CorruptImageError,
-              "UnexpectedEndOfFile",image->filename);
-            break;
-          }
+      if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+          image->filename);
     }
   /*
     Create virtual canvas to support cropping (i.e. image.rgb[100x100+10+20]).
@@ -636,13 +632,9 @@ static Image *ReadRGBImage(const ImageInfo *image_info,
             image=DestroyImageList(image);
             return((Image *) NULL);
           }
-        for (i=0; i < image->offset; i++)
-          if (ReadBlobByte(image) == EOF)
-            {
-              ThrowFileException(exception,CorruptImageError,
-                "UnexpectedEndOfFile",image->filename);
-              break;
-            }
+        if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+          ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+            image->filename);
         length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
         for (i=0; i < (ssize_t) scene; i++)
           for (y=0; y < (ssize_t) image->extract_info.height; y++)
index 0ac925327ea6f35ef439064690747324e2e03fa5..8d1506de46389ec5b49d9ab3bcd225659088a6f3 100644 (file)
@@ -139,13 +139,9 @@ static Image *ReadUYVYImage(const ImageInfo *image_info,
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
     return((Image *) NULL);
-  for (i=0; i < image->offset; i++)
-    if (ReadBlobByte(image) == EOF)
-      {
-        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
-          image->filename);
-        break;
-      }
+  if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+    ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+      image->filename);
   image->depth=8;
   if (image_info->ping != MagickFalse)
     {
index 12366de20118878cbee19e97454f7dc8c454ef5d..c94a9b5286211384caa24c2d73855f5a7f61cec4 100644 (file)
@@ -175,13 +175,9 @@ static Image *ReadWBMPImage(const ImageInfo *image_info,
     ThrowReaderException(CorruptImageError,"CorruptWBMPimage");
   if ((image->columns == 0) || (image->rows == 0))
     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
-  for (i=0; i < image->offset; i++)
-    if (ReadBlobByte(image) == EOF)
-      {
-        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
-          image->filename);
-        break;
-      }
+  if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+    ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+      image->filename);
   if (AcquireImageColormap(image,2) == MagickFalse)
     ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
   if (image_info->ping != MagickFalse)
index 4a7873142274821669908375392467b5d51e4d2f..7e39de625ac0ea6a7b582c5935fc869213abbcde 100644 (file)
@@ -841,8 +841,9 @@ static MagickBooleanType ReadOneLayer(Image* image,XCFDocInfo* inDocInfo,
       break;
      case PROP_PARASITES:
      {
-        for (i=0; i < (ssize_t) prop_size; i++ )
-          (void) ReadBlobByte(image);
+       if (DiscardBlobBytes(image,prop_size) == MagickFalse)
+         ThrowFileException(&image->exception,CorruptImageError,
+           "UnexpectedEndOfFile",image->filename);
 
         /*
        ssize_t base = info->cp;
@@ -1069,8 +1070,9 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
            by some Gimp versions.
         */
         size_t num_colours = ReadBlobMSBLong(image);
-        for (i=0; i < (ssize_t) (3L*num_colours); i++ )
-          (void) ReadBlobByte(image);
+        if (DiscardBlobBytes(image,3*num_colours) == MagickFalse)
+          ThrowFileException(&image->exception,CorruptImageError,
+            "UnexpectedEndOfFile",image->filename);
     /*
       if (info->file_version == 0)
       {
@@ -1116,10 +1118,9 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
       case PROP_GUIDES:
       {
          /* just skip it - we don't care about guides */
-        for (i=0; i < (ssize_t) prop_size; i++ )
-          if (ReadBlobByte(image) == EOF)
-            ThrowFileException(exception,CorruptImageError,
-              "UnexpectedEndOfFile",image->filename);
+        if (DiscardBlobBytes(image,prop_size) == MagickFalse)
+          ThrowFileException(&image->exception,CorruptImageError,
+            "UnexpectedEndOfFile",image->filename);
       }
       break;
 
@@ -1157,11 +1158,9 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     case PROP_PARASITES:
       {
         /* BOGUS: we may need these for IPTC stuff */
-        for (i=0; i < (ssize_t) prop_size; i++ )
-          if (ReadBlobByte(image) == EOF)
-            ThrowFileException(exception,CorruptImageError,
-              "UnexpectedEndOfFile",image->filename);
-
+        if (DiscardBlobBytes(image,prop_size) == MagickFalse)
+          ThrowFileException(&image->exception,CorruptImageError,
+            "UnexpectedEndOfFile",image->filename);
         /*
       gssize_t         base = info->cp;
       GimpParasite *p;
@@ -1188,10 +1187,9 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     case PROP_PATHS:
       {
       /* BOGUS: just skip it for now */
-        for (i=0; i< (ssize_t) prop_size; i++ )
-          if (ReadBlobByte(image) == EOF)
-            ThrowFileException(exception,CorruptImageError,
-              "UnexpectedEndOfFile",image->filename);
+        if (DiscardBlobBytes(image,prop_size) == MagickFalse)
+          ThrowFileException(&image->exception,CorruptImageError,
+            "UnexpectedEndOfFile",image->filename);
 
         /*
       PathList *paths = xcf_load_bzpaths (gimage, info);
index 6571699b08736b8a54223a40cd45bf9b70459024..ede8af19498c716348bae7456e034bbfbeaa2e03 100644 (file)
@@ -158,13 +158,9 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
           image=DestroyImageList(image);
           return((Image *) NULL);
         }
-      for (i=0; i < image->offset; i++)
-        if (ReadBlobByte(image) == EOF)
-          {
-            ThrowFileException(exception,CorruptImageError,
-              "UnexpectedEndOfFile",image->filename);
-            break;
-          }
+      if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+          image->filename);
     }
   /*
     Create virtual canvas to support cropping (i.e. image.rgb[100x100+10+20]).
@@ -555,13 +551,9 @@ static Image *ReadYCBCRImage(const ImageInfo *image_info,
             image=DestroyImageList(image);
             return((Image *) NULL);
           }
-        for (i=0; i < image->offset; i++)
-          if (ReadBlobByte(image) == EOF)
-            {
-              ThrowFileException(exception,CorruptImageError,
-                "UnexpectedEndOfFile",image->filename);
-              break;
-            }
+        if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+          ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+            image->filename);
         length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
         for (i=0; i < (ssize_t) scene; i++)
           for (y=0; y < (ssize_t) image->extract_info.height; y++)
index 598130511940aec20250390dec9e5e806816c381..7a46c6d78ab08cbca7f307544ac3f4eef13cf4ca 100644 (file)
@@ -186,13 +186,9 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
           image=DestroyImageList(image);
           return((Image *) NULL);
         }
-      for (i=0; i < image->offset; i++)
-        if (ReadBlobByte(image) == EOF)
-          {
-            ThrowFileException(exception,CorruptImageError,
-              "UnexpectedEndOfFile",image->filename);
-            break;
-          }
+      if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+        ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+          image->filename);
     }
   /*
     Allocate memory for a scanline.