]> granicus.if.org Git - imagemagick/commitdiff
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5678
authorCristy <urban-warrior@imagemagick.org>
Sun, 4 Feb 2018 21:01:42 +0000 (16:01 -0500)
committerCristy <urban-warrior@imagemagick.org>
Sun, 4 Feb 2018 21:01:42 +0000 (16:01 -0500)
coders/sun.c

index 2c28a801b76771835f038d9ff1dd0bd0c4ddf3f9..b36a9ea23182cc3fc2bf71c79b2eb71e6de065d8 100644 (file)
@@ -313,6 +313,8 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
     sun_info.type=ReadBlobMSBLong(image);
     sun_info.maptype=ReadBlobMSBLong(image);
     sun_info.maplength=ReadBlobMSBLong(image);
+    if (sun_info.maplength > GetBlobSize(image))
+      ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
     extent=sun_info.height*sun_info.width;
     if ((sun_info.height != 0) && (sun_info.width != extent/sun_info.height))
       ThrowReaderException(CorruptImageError,"ImproperImageHeader");
@@ -336,8 +338,6 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
         size_t
           one;
 
-        if (sun_info.maplength > GetBlobSize(image))
-          ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
         image->colors=sun_info.maplength;
         one=1;
         if (sun_info.maptype == RMT_NONE)