From 107cd466a8476517d25cb23d5dbc77877d12b29d Mon Sep 17 00:00:00 2001 From: Cristy Date: Sun, 4 Feb 2018 16:01:42 -0500 Subject: [PATCH] https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5678 --- coders/sun.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) -- 2.40.0