Commit fe20c950a for imagemagick.org
commit fe20c950a7ee8b965a9a061ac97d695bcb308d63
Author: Cristy <urban-warrior@imagemagick.org>
Date: Thu Jun 4 19:57:36 2026 -0400
https://github.com/ImageMagick/ImageMagick/security/advisories/GHSA-c8r2-mc3p-4f8j
diff --git a/coders/pdf.c b/coders/pdf.c
index fe159d415..c17814f75 100644
--- a/coders/pdf.c
+++ b/coders/pdf.c
@@ -488,9 +488,9 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
(void) ParseAbsoluteGeometry(PSPageGeometry,&page);
if (image_info->page != (char *) NULL)
(void) ParseAbsoluteGeometry(image_info->page,&page);
- page.width=(size_t) ((ssize_t) ceil((double) (page.width*
+ page.width=CastDoubleToSizeT(((double) (page.width*
image->resolution.x/delta.x)-0.5));
- page.height=(size_t) ((ssize_t) ceil((double) (page.height*
+ page.height=CastDoubleToSizeT(((double) (page.height*
image->resolution.y/delta.y)-0.5));
/*
Determine page geometry from the PDF media box.
@@ -531,9 +531,9 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
image=DestroyImage(image);
return((Image *) NULL);
}
- page.width=(size_t) ((ssize_t) ceil((double) (page.width*
+ page.width=CastDoubleToSizeT(((double) (page.width*
image->resolution.x/delta.x)-0.5));
- page.height=(size_t) ((ssize_t) ceil((double) (page.height*
+ page.height=CastDoubleToSizeT(((double) (page.height*
image->resolution.y/delta.y)-0.5));
fitPage=MagickTrue;
}
diff --git a/coders/ps.c b/coders/ps.c
index d2ea34588..57bb7454f 100644
--- a/coders/ps.c
+++ b/coders/ps.c
@@ -672,9 +672,9 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
if (image_info->page != (char *) NULL)
(void) ParseAbsoluteGeometry(image_info->page,&page);
resolution=image->resolution;
- page.width=(size_t) ((ssize_t) ceil((double) (page.width*resolution.x/
+ page.width=CastDoubleToSizeT(((double) (page.width*resolution.x/
delta.x)-0.5));
- page.height=(size_t) ((ssize_t) ceil((double) (page.height*resolution.y/
+ page.height=CastDoubleToSizeT(((double) (page.height*resolution.y/
delta.y)-0.5));
/*
Determine page geometry from the Postscript bounding box.
@@ -690,9 +690,9 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
(void) FormatImageProperty(image,"ps:HiResBoundingBox",
"%gx%g%+.15g%+.15g",info.bounds.x2-info.bounds.x1,info.bounds.y2-
info.bounds.y1,info.bounds.x1,info.bounds.y1);
- page.width=(size_t) ((ssize_t) ceil((double) ((info.bounds.x2-
+ page.width=CastDoubleToSizeT(((double) ((info.bounds.x2-
info.bounds.x1)*resolution.x/delta.x)-0.5));
- page.height=(size_t) ((ssize_t) ceil((double) ((info.bounds.y2-
+ page.height=CastDoubleToSizeT(((double) ((info.bounds.y2-
info.bounds.y1)*resolution.y/delta.y)-0.5));
}
fitPage=MagickFalse;
@@ -714,9 +714,9 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
image=DestroyImage(image);
return((Image *) NULL);
}
- page.width=(size_t) ((ssize_t) ceil((double) (page.width*
+ page.width=CastDoubleToSizeT(((double) (page.width*
image->resolution.x/delta.x)-0.5));
- page.height=(size_t) ((ssize_t) ceil((double) (page.height*
+ page.height=CastDoubleToSizeT(((double) (page.height*
image->resolution.y/delta.y) -0.5));
fitPage=MagickTrue;
}
diff --git a/coders/xps.c b/coders/xps.c
index 8905410d0..63e5395c4 100644
--- a/coders/xps.c
+++ b/coders/xps.c
@@ -228,9 +228,9 @@ static Image *ReadXPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
if (image_info->page != (char *) NULL)
(void) ParseAbsoluteGeometry(image_info->page,&page);
resolution=image->resolution;
- page.width=(size_t) ((ssize_t) ceil((double) (page.width*resolution.x/
+ page.width=CastDoubleToSizeT(((double) (page.width*resolution.x/
delta.x)-0.5));
- page.height=(size_t) ((ssize_t) ceil((double) (page.height*resolution.y/
+ page.height=CastDoubleToSizeT(((double) (page.height*resolution.y/
delta.y)-0.5));
fitPage=MagickFalse;
option=GetImageOption(image_info,"xps:fit-page");
@@ -250,9 +250,9 @@ static Image *ReadXPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
image=DestroyImage(image);
return((Image *) NULL);
}
- page.width=(size_t) ((ssize_t) ceil((double) (page.width*
+ page.width=CastDoubleToSizeT(((double) (page.width*
image->resolution.x/delta.x)-0.5));
- page.height=(size_t) ((ssize_t) ceil((double) (page.height*
+ page.height=CastDoubleToSizeT(((double) (page.height*
image->resolution.y/delta.y) -0.5));
page_geometry=DestroyString(page_geometry);
fitPage=MagickTrue;