Commit 351bbc833 for imagemagick.org
commit 351bbc8330269b56e0024772f814b61c66675590
Author: Dirk Lemstra <dirk@lemstra.org>
Date: Tue Dec 2 22:56:23 2025 +0100
Use HeapOverflowSanityCheckGetSize to make it more clear what is happening.
diff --git a/coders/sun.c b/coders/sun.c
index 0f173acac..fa2486764 100644
--- a/coders/sun.c
+++ b/coders/sun.c
@@ -315,8 +315,7 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
sun_info.maplength=ReadBlobMSBLong(image);
if (sun_info.maplength > GetBlobSize(image))
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
- extent=(size_t) (sun_info.height*sun_info.width);
- if ((sun_info.height != 0) && (sun_info.width != (extent/sun_info.height)))
+ if (HeapOverflowSanityCheckGetSize(sun_info.width,sun_info.height,&extent) != MagickFalse)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
if ((sun_info.type != RT_STANDARD) && (sun_info.type != RT_ENCODED) &&
(sun_info.type != RT_FORMAT_RGB))