]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Thu, 29 Sep 2016 23:38:34 +0000 (19:38 -0400)
committerCristy <urban-warrior@imagemagick.org>
Thu, 29 Sep 2016 23:38:34 +0000 (19:38 -0400)
coders/xcf.c

index 4c708a0d8ecfbf32fee262097f588f711cb0262f..f5ea575cd7d6502af2fbbf7b5bef99675b49cce8 100644 (file)
@@ -645,7 +645,9 @@ static MagickBooleanType load_level(Image *image,XCFDocInfo *inDocInfo,
     if (offset2 == 0)
       offset2=(MagickOffsetType) (offset + TILE_WIDTH * TILE_WIDTH * 4* 1.5);
     /* seek to the tile offset */
-    offset=SeekBlob(image, offset, SEEK_SET);
+    if (SeekBlob(image, offset, SEEK_SET) != offset)
+      ThrowBinaryException(CorruptImageError,"InsufficientImageDataInFile",
+        image->filename);
 
       /*
         Allocate the image for the tile.  NOTE: the last tile in a row or
@@ -748,7 +750,9 @@ static MagickBooleanType load_hierarchy(Image *image,XCFDocInfo *inDocInfo,
   saved_pos=TellBlob(image);
 
   /* seek to the level offset */
-  offset=SeekBlob(image, offset, SEEK_SET);
+  if (SeekBlob(image, offset, SEEK_SET) != offset)
+    ThrowBinaryException(CorruptImageError,"InsufficientImageDataInFile",
+      image->filename);
 
   /* read in the level */
   if (load_level (image, inDocInfo, inLayer, exception) == 0)
@@ -792,6 +796,9 @@ static MagickBooleanType ReadOneLayer(const ImageInfo *image_info,Image* image,
   outLayer->type = ReadBlobMSBLong(image);
   (void) ReadBlobStringWithLongSize(image, outLayer->name,
     sizeof(outLayer->name),exception);
+  if (EOFBlob(image) != MagickFalse)
+    ThrowBinaryException(CorruptImageError,"InsufficientImageDataInFile",
+      image->filename);
   /* read the layer properties! */
   foundPropEnd = 0;
   while ( (foundPropEnd == MagickFalse) && (EOFBlob(image) == MagickFalse) ) {
@@ -925,7 +932,7 @@ static MagickBooleanType ReadOneLayer(const ImageInfo *image_info,Image* image,
 
   /* read in the hierarchy */
   offset=SeekBlob(image, (MagickOffsetType) hierarchy_offset, SEEK_SET);
-  if (offset < 0)
+  if (offset != (MagickOffsetType) hierarchy_offset)
     (void) ThrowMagickException(exception,GetMagickModule(),
       CorruptImageError,"InvalidImageHeader","`%s'",image->filename);
   if (load_hierarchy (image, inDocInfo, outLayer, exception) == 0)
@@ -1318,7 +1325,9 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
       */
       saved_pos=TellBlob(image);
       /* seek to the layer offset */
-      offset=SeekBlob(image,offset,SEEK_SET);
+      if (SeekBlob(image,offset,SEEK_SET) != offset)
+        ThrowBinaryException(CorruptImageError,"NotEnoughPixelData",
+          image->filename);
       /* read in the layer */
       layer_ok=ReadOneLayer(image_info,image,&doc_info,
         &layer_info[current_layer],current_layer,exception);