From: Cristy Date: Sun, 4 Feb 2018 21:01:42 +0000 (-0500) Subject: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5678 X-Git-Tag: 7.0.7-23~133 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=107cd466a8476517d25cb23d5dbc77877d12b29d;p=imagemagick https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5678 --- diff --git a/coders/sun.c b/coders/sun.c index 2c28a801b..b36a9ea23 100644 --- a/coders/sun.c +++ b/coders/sun.c @@ -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)