File ImageMagick-CVE-2025-66628.patch of Package ImageMagick.41948

From bdae0681ad1e572defe62df85834218f01e6d670 Mon Sep 17 00:00:00 2001
From: Dirk Lemstra <dirk@lemstra.org>
Date: Tue, 2 Dec 2025 22:49:12 +0100
Subject: [PATCH] Added extra check to avoid an overflow on 32-bit machines
 (GHSA-6hjr-v6g4-3fm8)

---
 coders/tim.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/coders/tim.c b/coders/tim.c
index db60f32e65a..b87e06d2ceb 100644
--- a/coders/tim.c
+++ b/coders/tim.c
@@ -231,7 +231,8 @@ static Image *ReadTIMImage(const ImageInfo *image_info,ExceptionInfo *exception)
     (void) ReadBlobLSBShort(image);
     width=ReadBlobLSBShort(image);
     height=ReadBlobLSBShort(image);
-    image_size=2*width*height;
+    if (HeapOverflowSanityCheckGetSize(2*width,height,&image_size) != MagickFalse)
+      ThrowReaderException(CorruptImageError,"ImproperImageHeader");
     if (image_size > GetBlobSize(image))
       ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
     bytes_per_line=width*2;

openSUSE Build Service is sponsored by