]> granicus.if.org Git - imagemagick/commitdiff
http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=26857
authorcristy <urban-warrior@git.imagemagick.org>
Sat, 10 Jan 2015 14:10:16 +0000 (14:10 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sat, 10 Jan 2015 14:10:16 +0000 (14:10 +0000)
coders/sun.c

index af1a7289bfadb11cd416762c1bbbce56c50f368c..728bffa4d31104b88603efe8ce5d3702a3acf893 100644 (file)
@@ -409,8 +409,8 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
         sun_info.length || !sun_info.length)
       ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
     number_pixels=(MagickSizeType) image->columns*image->rows;
-    if ((sun_info.type != RT_ENCODED) && (sun_info.depth >= 8) &&
-        ((number_pixels*((sun_info.depth+7)/8)) > sun_info.length))
+    if ((sun_info.type != RT_ENCODED) && 
+        ((number_pixels*sun_info.depth) > (8*sun_info.length)))
       ThrowReaderException(CorruptImageError,"ImproperImageHeader");
     bytes_per_line=sun_info.width*sun_info.depth;
     sun_data=(unsigned char *) AcquireQuantumMemory((size_t) MagickMax(
@@ -532,7 +532,7 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
             bytes_per_pixel++;
           if (bytes_per_line == 0)
             bytes_per_line=bytes_per_pixel*image->columns;
-          length=image->rows*(bytes_per_line+image->columns % 2);
+          length=image->rows*(bytes_per_line+bytes_per_line % 2);
           if (((sun_info.type == RT_ENCODED) &&
                (length > (bytes_per_line*image->rows))) ||
               ((sun_info.type != RT_ENCODED) && (length > sun_info.length)))