mirror of
git://git.openembedded.org/meta-openembedded
synced 2026-04-02 02:49:12 +00:00
ImageMagick: Fix CVE-2023-34151
Backport the fix for CVE-2023-34151
Upstream-Status: Backport [3d6d98d8a2]
Add below patch to fix
0011-ImageMagick-Fix-CVE-2023-34151.patch
Add below support patch to fix
0011-ImageMagick-Add-support-patch-1-to-fix-CVE-2023-3415.patch
0011-ImageMagick-Add-support-patch-2-to-fix-CVE-2023-3415.patch
0011-ImageMagick-Add-support-patch-3-to-fix-CVE-2023-3415.patch
Signed-off-by: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
This commit is contained in:
parent
3a86962b26
commit
2114ae5f26
@ -0,0 +1,75 @@
|
||||
From dd62bd8f2e1aa6822551c668d23b4d288390dcb7 Mon Sep 17 00:00:00 2001
|
||||
From: Cristy <urban-warrior@imagemagick.org>
|
||||
Date: Mon, 21 Feb 2022 11:55:43 -0500
|
||||
Subject: [PATCH 15/18] ImageMagick: Add support patch 1 to fix CVE-2023-34151
|
||||
|
||||
Upstream-Status: Backport [https://github.com/ImageMagick/ImageMagick/commit/eb0882667cddc4ea71b61a583a782c430220faf4]
|
||||
|
||||
Comment: Refreshed hunk to match latest kirkstone
|
||||
|
||||
Signed-off-by: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
|
||||
---
|
||||
MagickCore/image-private.h | 11 +++++++++++
|
||||
coders/txt.c | 24 ++++++++++++------------
|
||||
2 files changed, 23 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/MagickCore/image-private.h b/MagickCore/image-private.h
|
||||
index 40c8686d3..59b88fb6f 100644
|
||||
--- a/MagickCore/image-private.h
|
||||
+++ b/MagickCore/image-private.h
|
||||
@@ -61,6 +61,17 @@ static inline ssize_t CastDoubleToLong(const double value)
|
||||
return((ssize_t) value);
|
||||
}
|
||||
|
||||
+static inline QuantumAny CastDoubleToQuantumAny(const double x)
|
||||
+{
|
||||
+ if (IsNaN(x) != 0)
|
||||
+ return(0);
|
||||
+ if (x > ((double) ((QuantumAny) ~0)))
|
||||
+ return((QuantumAny) ~0);
|
||||
+ if (x < 0.0)
|
||||
+ return(0.0);
|
||||
+ return((QuantumAny) (x+0.5));
|
||||
+}
|
||||
+
|
||||
static inline double DegreesToRadians(const double degrees)
|
||||
{
|
||||
return((double) (MagickPI*degrees/180.0));
|
||||
diff --git a/coders/txt.c b/coders/txt.c
|
||||
index b9bd08ce5..f8312a4fd 100644
|
||||
--- a/coders/txt.c
|
||||
+++ b/coders/txt.c
|
||||
@@ -564,18 +564,18 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
|
||||
green+=(range+1)/2.0;
|
||||
blue+=(range+1)/2.0;
|
||||
}
|
||||
- pixel.red=(MagickRealType) ScaleAnyToQuantum((QuantumAny)
|
||||
- MagickMax(red+0.5,0.0),range);
|
||||
- pixel.green=(MagickRealType) ScaleAnyToQuantum((QuantumAny)
|
||||
- MagickMax(green+0.5,0.0),range);
|
||||
- pixel.blue=(MagickRealType) ScaleAnyToQuantum((QuantumAny)
|
||||
- MagickMax(blue+0.5,0.0),range);
|
||||
- pixel.black=(MagickRealType) ScaleAnyToQuantum((QuantumAny)
|
||||
- MagickMax(black+0.5,0.0),range);
|
||||
- pixel.alpha=(MagickRealType) ScaleAnyToQuantum((QuantumAny)
|
||||
- MagickMax(alpha+0.5,0.0),range);
|
||||
- q=GetAuthenticPixels(image,CastDoubleToLong(x_offset),
|
||||
- CastDoubleToLong(y_offset),1,1,exception);
|
||||
+ pixel.red=(MagickRealType) ScaleAnyToQuantum(CastDoubleToQuantumAny(
|
||||
+ red),range);
|
||||
+ pixel.green=(MagickRealType) ScaleAnyToQuantum(CastDoubleToQuantumAny(
|
||||
+ green),range);
|
||||
+ pixel.blue=(MagickRealType) ScaleAnyToQuantum(CastDoubleToQuantumAny(
|
||||
+ blue),range);
|
||||
+ pixel.black=(MagickRealType) ScaleAnyToQuantum(CastDoubleToQuantumAny(
|
||||
+ black),range);
|
||||
+ pixel.alpha=(MagickRealType) ScaleAnyToQuantum(CastDoubleToQuantumAny(
|
||||
+ alpha),range);
|
||||
+ q=GetAuthenticPixels(image,CastDoubleToLong(x_offset),CastDoubleToLong(
|
||||
+ y_offset),1,1,exception);
|
||||
if (q == (Quantum *) NULL)
|
||||
{
|
||||
status=MagickFalse;
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@ -0,0 +1,973 @@
|
||||
From 95a74f9639872c667213b9ce201c1a388d538d30 Mon Sep 17 00:00:00 2001
|
||||
From: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
|
||||
Date: Tue, 2 Dec 2025 14:02:56 +0530
|
||||
Subject: [PATCH 16/18] ImageMagick: Add support patch 2 to fix CVE-2023-34151
|
||||
|
||||
Upstream-Status: Backport [https://github.com/ImageMagick/ImageMagick/commit/f7b5682435d37ad5ea8142d69629c93228e6376d]
|
||||
|
||||
Comment: Refreshed hunk to match latest kirkstone
|
||||
|
||||
Signed-off-by: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
|
||||
---
|
||||
MagickCore/annotate.c | 8 ++---
|
||||
MagickCore/draw.c | 60 ++++++++++++++++++-------------------
|
||||
MagickCore/effect.c | 8 ++---
|
||||
MagickCore/gem.c | 2 +-
|
||||
MagickCore/geometry.c | 24 +++++++--------
|
||||
MagickCore/image-private.h | 37 ++++++++++++++++-------
|
||||
MagickCore/image.c | 20 ++++++-------
|
||||
MagickCore/pixel.c | 36 +++++++++++-----------
|
||||
MagickCore/property.c | 4 +--
|
||||
MagickCore/shear.c | 22 +++++++-------
|
||||
MagickCore/studio.h | 2 --
|
||||
MagickCore/transform.c | 4 +--
|
||||
MagickCore/visual-effects.c | 40 ++++++++++++-------------
|
||||
MagickWand/drawing-wand.c | 8 ++---
|
||||
MagickWand/studio.h | 2 --
|
||||
coders/histogram.c | 6 ++--
|
||||
coders/jpeg.c | 3 +-
|
||||
coders/png.c | 12 ++++----
|
||||
coders/tiff.c | 4 +--
|
||||
coders/txt.c | 4 +--
|
||||
20 files changed, 159 insertions(+), 147 deletions(-)
|
||||
|
||||
diff --git a/MagickCore/annotate.c b/MagickCore/annotate.c
|
||||
index 4be938be5..14f8d05d8 100644
|
||||
--- a/MagickCore/annotate.c
|
||||
+++ b/MagickCore/annotate.c
|
||||
@@ -1734,8 +1734,8 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
|
||||
|
||||
if (status == MagickFalse)
|
||||
continue;
|
||||
- x_offset=CastDoubleToLong(ceil(point.x-0.5));
|
||||
- y_offset=CastDoubleToLong(ceil(point.y+y-0.5));
|
||||
+ x_offset=CastDoubleToSSizeT(ceil(point.x-0.5));
|
||||
+ y_offset=CastDoubleToSSizeT(ceil(point.y+y-0.5));
|
||||
if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
|
||||
continue;
|
||||
q=(Quantum *) NULL;
|
||||
@@ -1750,7 +1750,7 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
|
||||
n=y*bitmap->bitmap.pitch;
|
||||
for (x=0; x < (ssize_t) bitmap->bitmap.width; x++, n++)
|
||||
{
|
||||
- x_offset=CastDoubleToLong(ceil(point.x+x-0.5));
|
||||
+ x_offset=CastDoubleToSSizeT(ceil(point.x+x-0.5));
|
||||
if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
|
||||
{
|
||||
if (q != (Quantum *) NULL)
|
||||
@@ -2102,7 +2102,7 @@ static MagickBooleanType RenderPostscript(Image *image,
|
||||
crop_info=GetImageBoundingBox(annotate_image,exception);
|
||||
crop_info.height=(size_t) ((resolution.y/DefaultResolution)*
|
||||
ExpandAffine(&draw_info->affine)*draw_info->pointsize+0.5);
|
||||
- crop_info.y=CastDoubleToLong(ceil((resolution.y/DefaultResolution)*
|
||||
+ crop_info.y=CastDoubleToSSizeT(ceil((resolution.y/DefaultResolution)*
|
||||
extent.y/8.0-0.5));
|
||||
(void) FormatLocaleString(geometry,MagickPathExtent,
|
||||
"%.20gx%.20g%+.20g%+.20g",(double) crop_info.width,(double)
|
||||
diff --git a/MagickCore/draw.c b/MagickCore/draw.c
|
||||
index facea115e..02df7d231 100644
|
||||
--- a/MagickCore/draw.c
|
||||
+++ b/MagickCore/draw.c
|
||||
@@ -1233,8 +1233,8 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
|
||||
edge.y2=MagickMin(max.y,(double) image->rows-1.0);
|
||||
inverse_affine=InverseAffineMatrix(affine);
|
||||
GetPixelInfo(image,&zero);
|
||||
- start=CastDoubleToLong(ceil(edge.y1-0.5));
|
||||
- stop=CastDoubleToLong(floor(edge.y2+0.5));
|
||||
+ start=CastDoubleToSSizeT(ceil(edge.y1-0.5));
|
||||
+ stop=CastDoubleToSSizeT(floor(edge.y2+0.5));
|
||||
source_view=AcquireVirtualCacheView(source,exception);
|
||||
image_view=AcquireAuthenticCacheView(image,exception);
|
||||
#if defined(MAGICKCORE_OPENMP_SUPPORT)
|
||||
@@ -1267,16 +1267,16 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
|
||||
inverse_edge=AffineEdge(source,&inverse_affine,(double) y,&edge);
|
||||
if (inverse_edge.x2 < inverse_edge.x1)
|
||||
continue;
|
||||
- q=GetCacheViewAuthenticPixels(image_view,CastDoubleToLong(
|
||||
- ceil(inverse_edge.x1-0.5)),y,(size_t) CastDoubleToLong(floor(
|
||||
+ q=GetCacheViewAuthenticPixels(image_view,CastDoubleToSSizeT(
|
||||
+ ceil(inverse_edge.x1-0.5)),y,(size_t) CastDoubleToSSizeT(floor(
|
||||
inverse_edge.x2+0.5)-ceil(inverse_edge.x1-0.5)+1),1,exception);
|
||||
if (q == (Quantum *) NULL)
|
||||
continue;
|
||||
pixel=zero;
|
||||
composite=zero;
|
||||
x_offset=0;
|
||||
- for (x=CastDoubleToLong(ceil(inverse_edge.x1-0.5));
|
||||
- x <= CastDoubleToLong(floor(inverse_edge.x2+0.5)); x++)
|
||||
+ for (x=CastDoubleToSSizeT(ceil(inverse_edge.x1-0.5));
|
||||
+ x <= CastDoubleToSSizeT(floor(inverse_edge.x2+0.5)); x++)
|
||||
{
|
||||
point.x=(double) x*inverse_affine.sx+y*inverse_affine.ry+
|
||||
inverse_affine.tx;
|
||||
@@ -2090,8 +2090,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
|
||||
case UndefinedSpread:
|
||||
case PadSpread:
|
||||
{
|
||||
- if ((x != CastDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
|
||||
- (y != CastDoubleToLong(ceil(gradient_vector->y1-0.5))))
|
||||
+ if ((x != CastDoubleToSSizeT(ceil(gradient_vector->x1-0.5))) ||
|
||||
+ (y != CastDoubleToSSizeT(ceil(gradient_vector->y1-0.5))))
|
||||
{
|
||||
offset=GetStopColorOffset(gradient,x,y);
|
||||
if (gradient->type != RadialGradient)
|
||||
@@ -2118,8 +2118,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
|
||||
}
|
||||
case ReflectSpread:
|
||||
{
|
||||
- if ((x != CastDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
|
||||
- (y != CastDoubleToLong(ceil(gradient_vector->y1-0.5))))
|
||||
+ if ((x != CastDoubleToSSizeT(ceil(gradient_vector->x1-0.5))) ||
|
||||
+ (y != CastDoubleToSSizeT(ceil(gradient_vector->y1-0.5))))
|
||||
{
|
||||
offset=GetStopColorOffset(gradient,x,y);
|
||||
if (gradient->type != RadialGradient)
|
||||
@@ -2160,8 +2160,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
|
||||
|
||||
antialias=MagickFalse;
|
||||
repeat=0.0;
|
||||
- if ((x != CastDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
|
||||
- (y != CastDoubleToLong(ceil(gradient_vector->y1-0.5))))
|
||||
+ if ((x != CastDoubleToSSizeT(ceil(gradient_vector->x1-0.5))) ||
|
||||
+ (y != CastDoubleToSSizeT(ceil(gradient_vector->y1-0.5))))
|
||||
{
|
||||
offset=GetStopColorOffset(gradient,x,y);
|
||||
if (gradient->type == LinearGradient)
|
||||
@@ -3457,21 +3457,21 @@ static MagickBooleanType RenderMVGContent(Image *image,
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
(void) CopyMagickString(name,token,MagickPathExtent);
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- bounds.x=CastDoubleToLong(ceil(GetDrawValue(token,
|
||||
+ bounds.x=CastDoubleToSSizeT(ceil(GetDrawValue(token,
|
||||
&next_token)-0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
if (*token == ',')
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- bounds.y=CastDoubleToLong(ceil(GetDrawValue(token,
|
||||
+ bounds.y=CastDoubleToSSizeT(ceil(GetDrawValue(token,
|
||||
&next_token)-0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
if (*token == ',')
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- bounds.width=(size_t) CastDoubleToLong(floor(GetDrawValue(
|
||||
+ bounds.width=(size_t) CastDoubleToSSizeT(floor(GetDrawValue(
|
||||
token,&next_token)+0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
@@ -3882,28 +3882,28 @@ static MagickBooleanType RenderMVGContent(Image *image,
|
||||
if (LocaleCompare("viewbox",keyword) == 0)
|
||||
{
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- graphic_context[n]->viewbox.x=CastDoubleToLong(ceil(
|
||||
+ graphic_context[n]->viewbox.x=CastDoubleToSSizeT(ceil(
|
||||
GetDrawValue(token,&next_token)-0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
if (*token == ',')
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- graphic_context[n]->viewbox.y=CastDoubleToLong(ceil(
|
||||
+ graphic_context[n]->viewbox.y=CastDoubleToSSizeT(ceil(
|
||||
GetDrawValue(token,&next_token)-0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
if (*token == ',')
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- graphic_context[n]->viewbox.width=(size_t) CastDoubleToLong(
|
||||
+ graphic_context[n]->viewbox.width=(size_t) CastDoubleToSSizeT(
|
||||
floor(GetDrawValue(token,&next_token)+0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
if (*token == ',')
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- graphic_context[n]->viewbox.height=(size_t) CastDoubleToLong(
|
||||
+ graphic_context[n]->viewbox.height=(size_t) CastDoubleToSSizeT(
|
||||
floor(GetDrawValue(token,&next_token)+0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
@@ -5017,8 +5017,8 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
|
||||
GetPixelInfo(image,&pixel);
|
||||
for ( ; x <= stop_x; x++)
|
||||
{
|
||||
- if ((x == CastDoubleToLong(ceil(primitive_info->point.x-0.5))) &&
|
||||
- (y == CastDoubleToLong(ceil(primitive_info->point.y-0.5))))
|
||||
+ if ((x == CastDoubleToSSizeT(ceil(primitive_info->point.x-0.5))) &&
|
||||
+ (y == CastDoubleToSSizeT(ceil(primitive_info->point.y-0.5))))
|
||||
{
|
||||
GetFillColor(draw_info,x-start_x,y-start_y,&pixel,exception);
|
||||
SetPixelViaPixelInfo(image,&pixel,q);
|
||||
@@ -5164,8 +5164,8 @@ static void LogPrimitiveInfo(const PrimitiveInfo *primitive_info)
|
||||
coordinates,
|
||||
y;
|
||||
|
||||
- x=CastDoubleToLong(ceil(primitive_info->point.x-0.5));
|
||||
- y=CastDoubleToLong(ceil(primitive_info->point.y-0.5));
|
||||
+ x=CastDoubleToSSizeT(ceil(primitive_info->point.x-0.5));
|
||||
+ y=CastDoubleToSSizeT(ceil(primitive_info->point.y-0.5));
|
||||
switch (primitive_info->primitive)
|
||||
{
|
||||
case AlphaPrimitive:
|
||||
@@ -5278,8 +5278,8 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
|
||||
status&=SetImageMask(image,CompositePixelMask,draw_info->composite_mask,
|
||||
exception);
|
||||
}
|
||||
- x=CastDoubleToLong(ceil(primitive_info->point.x-0.5));
|
||||
- y=CastDoubleToLong(ceil(primitive_info->point.y-0.5));
|
||||
+ x=CastDoubleToSSizeT(ceil(primitive_info->point.x-0.5));
|
||||
+ y=CastDoubleToSSizeT(ceil(primitive_info->point.y-0.5));
|
||||
image_view=AcquireAuthenticCacheView(image,exception);
|
||||
switch (primitive_info->primitive)
|
||||
{
|
||||
@@ -5557,8 +5557,8 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
|
||||
composite_images=DestroyImageList(composite_images);
|
||||
(void) SetImageProgressMonitor(composite_image,(MagickProgressMonitor)
|
||||
NULL,(void *) NULL);
|
||||
- x1=CastDoubleToLong(ceil(primitive_info[1].point.x-0.5));
|
||||
- y1=CastDoubleToLong(ceil(primitive_info[1].point.y-0.5));
|
||||
+ x1=CastDoubleToSSizeT(ceil(primitive_info[1].point.x-0.5));
|
||||
+ y1=CastDoubleToSSizeT(ceil(primitive_info[1].point.y-0.5));
|
||||
if (((x1 != 0L) && (x1 != (ssize_t) composite_image->columns)) ||
|
||||
((y1 != 0L) && (y1 != (ssize_t) composite_image->rows)))
|
||||
{
|
||||
@@ -6167,7 +6167,7 @@ static MagickBooleanType TraceArcPath(MVGInfo *mvg_info,const PointInfo start,
|
||||
else
|
||||
if ((theta > 0.0) && (sweep == MagickFalse))
|
||||
theta-=2.0*MagickPI;
|
||||
- arc_segments=(size_t) CastDoubleToLong(ceil(fabs((double) (theta/(0.5*
|
||||
+ arc_segments=(size_t) CastDoubleToSSizeT(ceil(fabs((double) (theta/(0.5*
|
||||
MagickPI+MagickEpsilon)))));
|
||||
status=MagickTrue;
|
||||
p=primitive_info;
|
||||
@@ -7517,7 +7517,7 @@ static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info,
|
||||
theta.q=atan2(box_q[2].y-center.y,box_q[2].x-center.x);
|
||||
if (theta.q < theta.p)
|
||||
theta.q+=2.0*MagickPI;
|
||||
- arc_segments=(size_t) CastDoubleToLong(ceil((double) ((theta.
|
||||
+ arc_segments=(size_t) CastDoubleToSSizeT(ceil((double) ((theta.
|
||||
q-theta.p)/(2.0*sqrt(PerceptibleReciprocal(mid))))));
|
||||
CheckPathExtent(MaxStrokePad,arc_segments+MaxStrokePad);
|
||||
stroke_q[q].x=box_q[1].x;
|
||||
@@ -7590,7 +7590,7 @@ static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info,
|
||||
theta.q=atan2(box_p[2].y-center.y,box_p[2].x-center.x);
|
||||
if (theta.p < theta.q)
|
||||
theta.p+=2.0*MagickPI;
|
||||
- arc_segments=(size_t) CastDoubleToLong(ceil((double) ((theta.p-
|
||||
+ arc_segments=(size_t) CastDoubleToSSizeT(ceil((double) ((theta.p-
|
||||
theta.q)/(2.0*sqrt((double) (1.0/mid))))));
|
||||
CheckPathExtent(arc_segments+MaxStrokePad,MaxStrokePad);
|
||||
stroke_p[p++]=box_p[1];
|
||||
diff --git a/MagickCore/effect.c b/MagickCore/effect.c
|
||||
index bfb1363f2..a37a1999e 100644
|
||||
--- a/MagickCore/effect.c
|
||||
+++ b/MagickCore/effect.c
|
||||
@@ -288,7 +288,7 @@ MagickExport Image *AdaptiveBlurImage(const Image *image,const double radius,
|
||||
center,
|
||||
j;
|
||||
|
||||
- j=CastDoubleToLong(ceil((double) width*(1.0-QuantumScale*
|
||||
+ j=CastDoubleToSSizeT(ceil((double) width*(1.0-QuantumScale*
|
||||
GetPixelIntensity(edge_image,r))-0.5));
|
||||
if (j < 0)
|
||||
j=0;
|
||||
@@ -609,7 +609,7 @@ MagickExport Image *AdaptiveSharpenImage(const Image *image,const double radius,
|
||||
center,
|
||||
j;
|
||||
|
||||
- j=CastDoubleToLong(ceil((double) width*(1.0-QuantumScale*
|
||||
+ j=CastDoubleToSSizeT(ceil((double) width*(1.0-QuantumScale*
|
||||
GetPixelIntensity(edge_image,r))-0.5));
|
||||
if (j < 0)
|
||||
j=0;
|
||||
@@ -2402,9 +2402,9 @@ MagickExport Image *MotionBlurImage(const Image *image,const double radius,
|
||||
point.y=(double) width*cos(DegreesToRadians(angle));
|
||||
for (i=0; i < (ssize_t) width; i++)
|
||||
{
|
||||
- offset[i].x=CastDoubleToLong(ceil((double) (i*point.y)/
|
||||
+ offset[i].x=CastDoubleToSSizeT(ceil((double) (i*point.y)/
|
||||
hypot(point.x,point.y)-0.5));
|
||||
- offset[i].y=CastDoubleToLong(ceil((double) (i*point.x)/
|
||||
+ offset[i].y=CastDoubleToSSizeT(ceil((double) (i*point.x)/
|
||||
hypot(point.x,point.y)-0.5));
|
||||
}
|
||||
/*
|
||||
diff --git a/MagickCore/gem.c b/MagickCore/gem.c
|
||||
index 2c5911f67..4eb8c3fc5 100644
|
||||
--- a/MagickCore/gem.c
|
||||
+++ b/MagickCore/gem.c
|
||||
@@ -692,7 +692,7 @@ MagickPrivate void ConvertHWBToRGB(const double hue,const double whiteness,
|
||||
*blue=QuantumRange*v;
|
||||
return;
|
||||
}
|
||||
- i=CastDoubleToLong(floor(6.0*hue));
|
||||
+ i=CastDoubleToSSizeT(floor(6.0*hue));
|
||||
f=6.0*hue-i;
|
||||
if ((i & 0x01) != 0)
|
||||
f=1.0-f;
|
||||
diff --git a/MagickCore/geometry.c b/MagickCore/geometry.c
|
||||
index 5c6e2ad69..dd46a96fc 100644
|
||||
--- a/MagickCore/geometry.c
|
||||
+++ b/MagickCore/geometry.c
|
||||
@@ -241,7 +241,7 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
|
||||
if (LocaleNCompare(p,"0x",2) == 0)
|
||||
*width=(size_t) strtol(p,&p,10);
|
||||
else
|
||||
- *width=((size_t) floor(StringToDouble(p,&p)+0.5)) & 0x7fffffff;
|
||||
+ *width=CastDoubleToSizeT(StringToDouble(p,&p));
|
||||
}
|
||||
if (p != q)
|
||||
flags|=WidthValue;
|
||||
@@ -260,7 +260,7 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
|
||||
*/
|
||||
q=p;
|
||||
if (height != (size_t *) NULL)
|
||||
- *height=((size_t) floor(StringToDouble(p,&p)+0.5)) & 0x7fffffff;
|
||||
+ *height=CastDoubleToSizeT(StringToDouble(p,&p));
|
||||
if (p != q)
|
||||
flags|=HeightValue;
|
||||
}
|
||||
@@ -279,7 +279,7 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
|
||||
}
|
||||
q=p;
|
||||
if (x != (ssize_t *) NULL)
|
||||
- *x=((ssize_t) ceil(StringToDouble(p,&p)-0.5)) & 0x7fffffff;
|
||||
+ *x=CastDoubleToSSizeT(StringToDouble(p,&p));
|
||||
if (p != q)
|
||||
{
|
||||
flags|=XValue;
|
||||
@@ -300,7 +300,7 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
|
||||
}
|
||||
q=p;
|
||||
if (y != (ssize_t *) NULL)
|
||||
- *y=((ssize_t) ceil(StringToDouble(p,&p)-0.5)) & 0x7fffffff;
|
||||
+ *y=CastDoubleToSSizeT(StringToDouble(p,&p));
|
||||
if (p != q)
|
||||
{
|
||||
flags|=YValue;
|
||||
@@ -1285,8 +1285,8 @@ MagickExport MagickStatusType ParseGravityGeometry(const Image *image,
|
||||
scale.y=geometry_info.sigma;
|
||||
if ((status & SigmaValue) == 0)
|
||||
scale.y=scale.x;
|
||||
- region_info->width=(size_t) floor((scale.x*image->columns/100.0)+0.5);
|
||||
- region_info->height=(size_t) floor((scale.y*image->rows/100.0)+0.5);
|
||||
+ region_info->width=CastDoubleToSizeT(scale.x*image->columns/100.0);
|
||||
+ region_info->height=CastDoubleToSizeT(scale.y*image->rows/100.0);
|
||||
}
|
||||
if ((flags & AspectRatioValue) != 0)
|
||||
{
|
||||
@@ -1308,13 +1308,13 @@ MagickExport MagickStatusType ParseGravityGeometry(const Image *image,
|
||||
if (geometry_ratio >= image_ratio)
|
||||
{
|
||||
region_info->width=image->columns;
|
||||
- region_info->height=(size_t) floor((double) (image->rows*image_ratio/
|
||||
- geometry_ratio)+0.5);
|
||||
+ region_info->height=CastDoubleToSizeT((double) image->rows*image_ratio/
|
||||
+ geometry_ratio);
|
||||
}
|
||||
else
|
||||
{
|
||||
- region_info->width=(size_t) floor((double) (image->columns*
|
||||
- geometry_ratio/image_ratio)+0.5);
|
||||
+ region_info->width=CastDoubleToSizeT((double) image->columns*
|
||||
+ geometry_ratio/image_ratio);
|
||||
region_info->height=image->rows;
|
||||
}
|
||||
}
|
||||
@@ -1450,8 +1450,8 @@ MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,ssize_t *x,
|
||||
}
|
||||
else
|
||||
{
|
||||
- *width=(size_t) floor((double) (PerceptibleReciprocal(
|
||||
- image_ratio)*former_width*geometry_ratio)+0.5);
|
||||
+ *width=CastDoubleToSizeT(PerceptibleReciprocal(
|
||||
+ image_ratio)*former_width*geometry_ratio);
|
||||
*height=former_height;
|
||||
}
|
||||
former_width=(*width);
|
||||
diff --git a/MagickCore/image-private.h b/MagickCore/image-private.h
|
||||
index 59b88fb6f..694c19d54 100644
|
||||
--- a/MagickCore/image-private.h
|
||||
+++ b/MagickCore/image-private.h
|
||||
@@ -41,6 +41,9 @@ extern "C" {
|
||||
#define MagickSQ1_2 0.70710678118654752440084436210484903928483593768847
|
||||
#define MagickSQ2 1.41421356237309504880168872420969807856967187537695
|
||||
#define MagickSQ2PI 2.50662827463100024161235523934010416269302368164062
|
||||
+#define MAGICK_SIZE_MAX (SIZE_MAX)
|
||||
+#define MAGICK_SSIZE_MAX (SSIZE_MAX)
|
||||
+#define MAGICK_SSIZE_MIN (-(SSIZE_MAX)-1)
|
||||
#define MatteColor "#bdbdbd" /* gray */
|
||||
#define PSDensityGeometry "72.0x72.0"
|
||||
#define PSPageGeometry "612x792"
|
||||
@@ -50,17 +53,6 @@ extern "C" {
|
||||
#define UndefinedCompressionQuality 0UL
|
||||
#define UndefinedTicksPerSecond 100L
|
||||
|
||||
-static inline ssize_t CastDoubleToLong(const double value)
|
||||
-{
|
||||
- if (IsNaN(value) != 0)
|
||||
- return(0);
|
||||
- if (value > (double) MAGICK_SSIZE_MAX)
|
||||
- return((ssize_t) MAGICK_SSIZE_MAX);
|
||||
- if (value < (double) MAGICK_SSIZE_MIN)
|
||||
- return((ssize_t) MAGICK_SSIZE_MIN);
|
||||
- return((ssize_t) value);
|
||||
-}
|
||||
-
|
||||
static inline QuantumAny CastDoubleToQuantumAny(const double x)
|
||||
{
|
||||
if (IsNaN(x) != 0)
|
||||
@@ -72,6 +64,29 @@ static inline QuantumAny CastDoubleToQuantumAny(const double x)
|
||||
return((QuantumAny) (x+0.5));
|
||||
}
|
||||
|
||||
+static inline size_t CastDoubleToSizeT(const double x)
|
||||
+{
|
||||
+ if (IsNaN(x) != 0)
|
||||
+ return(0);
|
||||
+ if (x > ((double) MAGICK_SIZE_MAX+0.5))
|
||||
+ return((size_t) MAGICK_SIZE_MAX);
|
||||
+ return((size_t) floor(x+0.5));
|
||||
+}
|
||||
+
|
||||
+static inline ssize_t CastDoubleToSSizeT(const double x)
|
||||
+{
|
||||
+ if (IsNaN(x) != 0)
|
||||
+ return(0);
|
||||
+ if (x > ((double) MAGICK_SSIZE_MAX+0.5))
|
||||
+ return((ssize_t) MAGICK_SSIZE_MAX);
|
||||
+ if (x < ((double) MAGICK_SSIZE_MIN-0.5))
|
||||
+ return((ssize_t) MAGICK_SSIZE_MIN);
|
||||
+ if (x >= 0.0)
|
||||
+ return((ssize_t) floor(x+0.5));
|
||||
+ return((ssize_t) ceil(x-0.5));
|
||||
+}
|
||||
+
|
||||
+
|
||||
static inline double DegreesToRadians(const double degrees)
|
||||
{
|
||||
return((double) (MagickPI*degrees/180.0));
|
||||
diff --git a/MagickCore/image.c b/MagickCore/image.c
|
||||
index 3e6fdd114..7b8caa0d2 100644
|
||||
--- a/MagickCore/image.c
|
||||
+++ b/MagickCore/image.c
|
||||
@@ -282,21 +282,21 @@ MagickExport Image *AcquireImage(const ImageInfo *image_info,
|
||||
if ((flags & GreaterValue) != 0)
|
||||
{
|
||||
if ((double) image->delay > floor(geometry_info.rho+0.5))
|
||||
- image->delay=(size_t) CastDoubleToLong(floor(
|
||||
+ image->delay=(size_t) CastDoubleToSSizeT(floor(
|
||||
geometry_info.rho+0.5));
|
||||
}
|
||||
else
|
||||
if ((flags & LessValue) != 0)
|
||||
{
|
||||
if ((double) image->delay < floor(geometry_info.rho+0.5))
|
||||
- image->ticks_per_second=CastDoubleToLong(floor(
|
||||
+ image->ticks_per_second=CastDoubleToSSizeT(floor(
|
||||
geometry_info.sigma+0.5));
|
||||
}
|
||||
else
|
||||
- image->delay=(size_t) CastDoubleToLong(floor(
|
||||
+ image->delay=(size_t) CastDoubleToSSizeT(floor(
|
||||
geometry_info.rho+0.5));
|
||||
if ((flags & SigmaValue) != 0)
|
||||
- image->ticks_per_second=CastDoubleToLong(floor(
|
||||
+ image->ticks_per_second=CastDoubleToSSizeT(floor(
|
||||
geometry_info.sigma+0.5));
|
||||
}
|
||||
option=GetImageOption(image_info,"dispose");
|
||||
@@ -881,18 +881,18 @@ MagickExport Image *CloneImage(const Image *image,const size_t columns,
|
||||
scale=1.0;
|
||||
if (image->columns != 0)
|
||||
scale=(double) columns/(double) image->columns;
|
||||
- clone_image->page.width=(size_t) CastDoubleToLong(floor(scale*
|
||||
+ clone_image->page.width=(size_t) CastDoubleToSSizeT(floor(scale*
|
||||
image->page.width+0.5));
|
||||
- clone_image->page.x=CastDoubleToLong(ceil(scale*image->page.x-0.5));
|
||||
- clone_image->tile_offset.x=CastDoubleToLong(ceil(scale*
|
||||
+ clone_image->page.x=CastDoubleToSSizeT(ceil(scale*image->page.x-0.5));
|
||||
+ clone_image->tile_offset.x=CastDoubleToSSizeT(ceil(scale*
|
||||
image->tile_offset.x-0.5));
|
||||
scale=1.0;
|
||||
if (image->rows != 0)
|
||||
scale=(double) rows/(double) image->rows;
|
||||
- clone_image->page.height=(size_t) CastDoubleToLong(floor(scale*
|
||||
+ clone_image->page.height=(size_t) CastDoubleToSSizeT(floor(scale*
|
||||
image->page.height+0.5));
|
||||
- clone_image->page.y=CastDoubleToLong(ceil(scale*image->page.y-0.5));
|
||||
- clone_image->tile_offset.y=CastDoubleToLong(ceil(scale*
|
||||
+ clone_image->page.y=CastDoubleToSSizeT(ceil(scale*image->page.y-0.5));
|
||||
+ clone_image->tile_offset.y=CastDoubleToSSizeT(ceil(scale*
|
||||
image->tile_offset.y-0.5));
|
||||
clone_image->cache=ClonePixelCache(image->cache);
|
||||
if (SetImageExtent(clone_image,columns,rows,exception) == MagickFalse)
|
||||
diff --git a/MagickCore/pixel.c b/MagickCore/pixel.c
|
||||
index 5c1c5296f..c2aea7c1d 100644
|
||||
--- a/MagickCore/pixel.c
|
||||
+++ b/MagickCore/pixel.c
|
||||
@@ -4515,8 +4515,8 @@ MagickExport MagickBooleanType InterpolatePixelChannel(
|
||||
status=MagickTrue;
|
||||
*pixel=0.0;
|
||||
traits=GetPixelChannelTraits(image,channel);
|
||||
- x_offset=CastDoubleToLong(floor(x));
|
||||
- y_offset=CastDoubleToLong(floor(y));
|
||||
+ x_offset=CastDoubleToSSizeT(floor(x));
|
||||
+ y_offset=CastDoubleToSSizeT(floor(y));
|
||||
interpolate=method;
|
||||
if (interpolate == UndefinedInterpolatePixel)
|
||||
interpolate=image->interpolate;
|
||||
@@ -4533,8 +4533,8 @@ MagickExport MagickBooleanType InterpolatePixelChannel(
|
||||
if (interpolate == Average9InterpolatePixel)
|
||||
{
|
||||
count=3;
|
||||
- x_offset=CastDoubleToLong(floor(x+0.5)-1.0);
|
||||
- y_offset=CastDoubleToLong(floor(y+0.5)-1.0);
|
||||
+ x_offset=CastDoubleToSSizeT(floor(x+0.5)-1.0);
|
||||
+ y_offset=CastDoubleToSSizeT(floor(y+0.5)-1.0);
|
||||
}
|
||||
else
|
||||
if (interpolate == Average16InterpolatePixel)
|
||||
@@ -4717,8 +4717,8 @@ MagickExport MagickBooleanType InterpolatePixelChannel(
|
||||
}
|
||||
case NearestInterpolatePixel:
|
||||
{
|
||||
- x_offset=CastDoubleToLong(floor(x+0.5));
|
||||
- y_offset=CastDoubleToLong(floor(y+0.5));
|
||||
+ x_offset=CastDoubleToSSizeT(floor(x+0.5));
|
||||
+ y_offset=CastDoubleToSSizeT(floor(y+0.5));
|
||||
p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset,1,1,exception);
|
||||
if (p == (const Quantum *) NULL)
|
||||
{
|
||||
@@ -4935,8 +4935,8 @@ MagickExport MagickBooleanType InterpolatePixelChannels(
|
||||
assert(source->signature == MagickCoreSignature);
|
||||
assert(source_view != (CacheView *) NULL);
|
||||
status=MagickTrue;
|
||||
- x_offset=CastDoubleToLong(floor(x));
|
||||
- y_offset=CastDoubleToLong(floor(y));
|
||||
+ x_offset=CastDoubleToSSizeT(floor(x));
|
||||
+ y_offset=CastDoubleToSSizeT(floor(y));
|
||||
interpolate=method;
|
||||
if (interpolate == UndefinedInterpolatePixel)
|
||||
interpolate=source->interpolate;
|
||||
@@ -4953,8 +4953,8 @@ MagickExport MagickBooleanType InterpolatePixelChannels(
|
||||
if (interpolate == Average9InterpolatePixel)
|
||||
{
|
||||
count=3;
|
||||
- x_offset=CastDoubleToLong(floor(x+0.5)-1.0);
|
||||
- y_offset=CastDoubleToLong(floor(y+0.5)-1.0);
|
||||
+ x_offset=CastDoubleToSSizeT(floor(x+0.5)-1.0);
|
||||
+ y_offset=CastDoubleToSSizeT(floor(y+0.5)-1.0);
|
||||
}
|
||||
else
|
||||
if (interpolate == Average16InterpolatePixel)
|
||||
@@ -5218,8 +5218,8 @@ MagickExport MagickBooleanType InterpolatePixelChannels(
|
||||
}
|
||||
case NearestInterpolatePixel:
|
||||
{
|
||||
- x_offset=CastDoubleToLong(floor(x+0.5));
|
||||
- y_offset=CastDoubleToLong(floor(y+0.5));
|
||||
+ x_offset=CastDoubleToSSizeT(floor(x+0.5));
|
||||
+ y_offset=CastDoubleToSSizeT(floor(y+0.5));
|
||||
p=GetCacheViewVirtualPixels(source_view,x_offset,y_offset,1,1,exception);
|
||||
if (p == (const Quantum *) NULL)
|
||||
{
|
||||
@@ -5502,8 +5502,8 @@ MagickExport MagickBooleanType InterpolatePixelInfo(const Image *image,
|
||||
assert(image->signature == MagickCoreSignature);
|
||||
assert(image_view != (CacheView *) NULL);
|
||||
status=MagickTrue;
|
||||
- x_offset=CastDoubleToLong(floor(x));
|
||||
- y_offset=CastDoubleToLong(floor(y));
|
||||
+ x_offset=CastDoubleToSSizeT(floor(x));
|
||||
+ y_offset=CastDoubleToSSizeT(floor(y));
|
||||
interpolate=method;
|
||||
if (interpolate == UndefinedInterpolatePixel)
|
||||
interpolate=image->interpolate;
|
||||
@@ -5522,8 +5522,8 @@ MagickExport MagickBooleanType InterpolatePixelInfo(const Image *image,
|
||||
if (interpolate == Average9InterpolatePixel)
|
||||
{
|
||||
count=3;
|
||||
- x_offset=CastDoubleToLong(floor(x+0.5)-1.0);
|
||||
- y_offset=CastDoubleToLong(floor(y+0.5)-1.0);
|
||||
+ x_offset=CastDoubleToSSizeT(floor(x+0.5)-1.0);
|
||||
+ y_offset=CastDoubleToSSizeT(floor(y+0.5)-1.0);
|
||||
}
|
||||
else if (interpolate == Average16InterpolatePixel)
|
||||
{
|
||||
@@ -5847,8 +5847,8 @@ MagickExport MagickBooleanType InterpolatePixelInfo(const Image *image,
|
||||
}
|
||||
case NearestInterpolatePixel:
|
||||
{
|
||||
- x_offset=CastDoubleToLong(floor(x+0.5));
|
||||
- y_offset=CastDoubleToLong(floor(y+0.5));
|
||||
+ x_offset=CastDoubleToSSizeT(floor(x+0.5));
|
||||
+ y_offset=CastDoubleToSSizeT(floor(y+0.5));
|
||||
p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset,1,1,exception);
|
||||
if (p == (const Quantum *) NULL)
|
||||
{
|
||||
diff --git a/MagickCore/property.c b/MagickCore/property.c
|
||||
index 1b42adaee..b13fa7a17 100644
|
||||
--- a/MagickCore/property.c
|
||||
+++ b/MagickCore/property.c
|
||||
@@ -4372,13 +4372,13 @@ MagickExport MagickBooleanType SetImageProperty(Image *image,
|
||||
if ((flags & LessValue) != 0)
|
||||
{
|
||||
if ((double) image->delay < floor(geometry_info.rho+0.5))
|
||||
- image->delay=CastDoubleToLong(
|
||||
+ image->delay=CastDoubleToSSizeT(
|
||||
floor(geometry_info.sigma+0.5));
|
||||
}
|
||||
else
|
||||
image->delay=(size_t) floor(geometry_info.rho+0.5);
|
||||
if ((flags & SigmaValue) != 0)
|
||||
- image->ticks_per_second=CastDoubleToLong(floor(
|
||||
+ image->ticks_per_second=CastDoubleToSSizeT(floor(
|
||||
geometry_info.sigma+0.5));
|
||||
return(MagickTrue);
|
||||
}
|
||||
diff --git a/MagickCore/shear.c b/MagickCore/shear.c
|
||||
index 05703ca34..62a98013e 100644
|
||||
--- a/MagickCore/shear.c
|
||||
+++ b/MagickCore/shear.c
|
||||
@@ -163,10 +163,10 @@ static MagickBooleanType CropToFitImage(Image **image,
|
||||
if (max.y < extent[i].y)
|
||||
max.y=extent[i].y;
|
||||
}
|
||||
- geometry.x=CastDoubleToLong(ceil(min.x-0.5));
|
||||
- geometry.y=CastDoubleToLong(ceil(min.y-0.5));
|
||||
- geometry.width=(size_t) CastDoubleToLong(floor(max.x-min.x+0.5));
|
||||
- geometry.height=(size_t) CastDoubleToLong(floor(max.y-min.y+0.5));
|
||||
+ geometry.x=CastDoubleToSSizeT(ceil(min.x-0.5));
|
||||
+ geometry.y=CastDoubleToSSizeT(ceil(min.y-0.5));
|
||||
+ geometry.width=(size_t) CastDoubleToSSizeT(floor(max.x-min.x+0.5));
|
||||
+ geometry.height=(size_t) CastDoubleToSSizeT(floor(max.y-min.y+0.5));
|
||||
page=(*image)->page;
|
||||
(void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
|
||||
crop_image=CropImage(*image,&geometry,exception);
|
||||
@@ -1217,7 +1217,7 @@ static MagickBooleanType XShearImage(Image *image,const double degrees,
|
||||
displacement*=(-1.0);
|
||||
direction=LEFT;
|
||||
}
|
||||
- step=CastDoubleToLong(floor((double) displacement));
|
||||
+ step=CastDoubleToSSizeT(floor((double) displacement));
|
||||
area=(double) (displacement-step);
|
||||
step++;
|
||||
pixel=background;
|
||||
@@ -1434,7 +1434,7 @@ static MagickBooleanType YShearImage(Image *image,const double degrees,
|
||||
displacement*=(-1.0);
|
||||
direction=UP;
|
||||
}
|
||||
- step=CastDoubleToLong(floor((double) displacement));
|
||||
+ step=CastDoubleToSSizeT(floor((double) displacement));
|
||||
area=(double) (displacement-step);
|
||||
step++;
|
||||
pixel=background;
|
||||
@@ -1617,11 +1617,11 @@ MagickExport Image *ShearImage(const Image *image,const double x_shear,
|
||||
/*
|
||||
Compute image size.
|
||||
*/
|
||||
- bounds.width=image->columns+CastDoubleToLong(floor(fabs(shear.x)*
|
||||
+ bounds.width=image->columns+CastDoubleToSSizeT(floor(fabs(shear.x)*
|
||||
image->rows+0.5));
|
||||
- bounds.x=CastDoubleToLong(ceil((double) image->columns+((fabs(shear.x)*
|
||||
+ bounds.x=CastDoubleToSSizeT(ceil((double) image->columns+((fabs(shear.x)*
|
||||
image->rows)-image->columns)/2.0-0.5));
|
||||
- bounds.y=CastDoubleToLong(ceil((double) image->rows+((fabs(shear.y)*
|
||||
+ bounds.y=CastDoubleToSSizeT(ceil((double) image->rows+((fabs(shear.y)*
|
||||
bounds.width)-image->rows)/2.0-0.5));
|
||||
/*
|
||||
Surround image with border.
|
||||
@@ -1770,9 +1770,9 @@ MagickExport Image *ShearRotateImage(const Image *image,const double degrees,
|
||||
bounds.height=(size_t) floor(fabs((double) bounds.width*shear.y)+height+0.5);
|
||||
shear_width=(size_t) floor(fabs((double) bounds.height*shear.x)+
|
||||
bounds.width+0.5);
|
||||
- bounds.x=CastDoubleToLong(floor((double) ((shear_width > bounds.width) ?
|
||||
+ bounds.x=CastDoubleToSSizeT(floor((double) ((shear_width > bounds.width) ?
|
||||
width : bounds.width-shear_width+2)/2.0+0.5));
|
||||
- bounds.y=CastDoubleToLong(floor(((double) bounds.height-height+2)/2.0+0.5));
|
||||
+ bounds.y=CastDoubleToSSizeT(floor(((double) bounds.height-height+2)/2.0+0.5));
|
||||
/*
|
||||
Surround image with a border.
|
||||
*/
|
||||
diff --git a/MagickCore/studio.h b/MagickCore/studio.h
|
||||
index fbdcc2d00..a0e8a9a1a 100644
|
||||
--- a/MagickCore/studio.h
|
||||
+++ b/MagickCore/studio.h
|
||||
@@ -350,8 +350,6 @@ extern int vsnprintf(char *,size_t,const char *,va_list);
|
||||
Magick defines.
|
||||
*/
|
||||
#define MagickMaxRecursionDepth 600
|
||||
-#define MAGICK_SSIZE_MAX (SSIZE_MAX)
|
||||
-#define MAGICK_SSIZE_MIN (-(SSIZE_MAX)-1)
|
||||
#define Swap(x,y) ((x)^=(y), (y)^=(x), (x)^=(y))
|
||||
#if defined(_MSC_VER)
|
||||
# define DisableMSCWarning(nr) __pragma(warning(push)) \
|
||||
diff --git a/MagickCore/transform.c b/MagickCore/transform.c
|
||||
index 385d5eb68..6afe0a3de 100644
|
||||
--- a/MagickCore/transform.c
|
||||
+++ b/MagickCore/transform.c
|
||||
@@ -773,8 +773,8 @@ static inline ssize_t PixelRoundOffset(double x)
|
||||
Round the fraction to nearest integer.
|
||||
*/
|
||||
if ((x-floor(x)) < (ceil(x)-x))
|
||||
- return(CastDoubleToLong(floor(x)));
|
||||
- return(CastDoubleToLong(ceil(x)));
|
||||
+ return(CastDoubleToSSizeT(floor(x)));
|
||||
+ return(CastDoubleToSSizeT(ceil(x)));
|
||||
}
|
||||
|
||||
MagickExport Image *CropImageToTiles(const Image *image,
|
||||
diff --git a/MagickCore/visual-effects.c b/MagickCore/visual-effects.c
|
||||
index 789660231..069904a08 100644
|
||||
--- a/MagickCore/visual-effects.c
|
||||
+++ b/MagickCore/visual-effects.c
|
||||
@@ -1439,8 +1439,8 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
*/
|
||||
depth--;
|
||||
attenuate++;
|
||||
- x_mid=CastDoubleToLong(ceil((segment->x1+segment->x2)/2-0.5));
|
||||
- y_mid=CastDoubleToLong(ceil((segment->y1+segment->y2)/2-0.5));
|
||||
+ x_mid=CastDoubleToSSizeT(ceil((segment->x1+segment->x2)/2-0.5));
|
||||
+ y_mid=CastDoubleToSSizeT(ceil((segment->y1+segment->y2)/2-0.5));
|
||||
local_info=(*segment);
|
||||
local_info.x2=(double) x_mid;
|
||||
local_info.y2=(double) y_mid;
|
||||
@@ -1463,8 +1463,8 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
&local_info,attenuate,depth,exception);
|
||||
return(status == 0 ? MagickFalse : MagickTrue);
|
||||
}
|
||||
- x_mid=CastDoubleToLong(ceil((segment->x1+segment->x2)/2-0.5));
|
||||
- y_mid=CastDoubleToLong(ceil((segment->y1+segment->y2)/2-0.5));
|
||||
+ x_mid=CastDoubleToSSizeT(ceil((segment->x1+segment->x2)/2-0.5));
|
||||
+ y_mid=CastDoubleToSSizeT(ceil((segment->y1+segment->y2)/2-0.5));
|
||||
if ((fabs(segment->x1-x_mid) < MagickEpsilon) &&
|
||||
(fabs(segment->x2-x_mid) < MagickEpsilon) &&
|
||||
(fabs(segment->y1-y_mid) < MagickEpsilon) &&
|
||||
@@ -1481,10 +1481,10 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
/*
|
||||
Left pixel.
|
||||
*/
|
||||
- x=CastDoubleToLong(ceil(segment->x1-0.5));
|
||||
- u=GetCacheViewVirtualPixels(u_view,x,CastDoubleToLong(ceil(
|
||||
+ x=CastDoubleToSSizeT(ceil(segment->x1-0.5));
|
||||
+ u=GetCacheViewVirtualPixels(u_view,x,CastDoubleToSSizeT(ceil(
|
||||
segment->y1-0.5)),1,1,exception);
|
||||
- v=GetCacheViewVirtualPixels(v_view,x,CastDoubleToLong(ceil(
|
||||
+ v=GetCacheViewVirtualPixels(v_view,x,CastDoubleToSSizeT(ceil(
|
||||
segment->y2-0.5)),1,1,exception);
|
||||
q=QueueCacheViewAuthenticPixels(image_view,x,y_mid,1,1,exception);
|
||||
if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
|
||||
@@ -1504,10 +1504,10 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
/*
|
||||
Right pixel.
|
||||
*/
|
||||
- x=CastDoubleToLong(ceil(segment->x2-0.5));
|
||||
- u=GetCacheViewVirtualPixels(u_view,x,CastDoubleToLong(ceil(
|
||||
+ x=CastDoubleToSSizeT(ceil(segment->x2-0.5));
|
||||
+ u=GetCacheViewVirtualPixels(u_view,x,CastDoubleToSSizeT(ceil(
|
||||
segment->y1-0.5)),1,1,exception);
|
||||
- v=GetCacheViewVirtualPixels(v_view,x,CastDoubleToLong(ceil(
|
||||
+ v=GetCacheViewVirtualPixels(v_view,x,CastDoubleToSSizeT(ceil(
|
||||
segment->y2-0.5)),1,1,exception);
|
||||
q=QueueCacheViewAuthenticPixels(image_view,x,y_mid,1,1,exception);
|
||||
if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
|
||||
@@ -1533,10 +1533,10 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
/*
|
||||
Bottom pixel.
|
||||
*/
|
||||
- y=CastDoubleToLong(ceil(segment->y2-0.5));
|
||||
- u=GetCacheViewVirtualPixels(u_view,CastDoubleToLong(ceil(
|
||||
+ y=CastDoubleToSSizeT(ceil(segment->y2-0.5));
|
||||
+ u=GetCacheViewVirtualPixels(u_view,CastDoubleToSSizeT(ceil(
|
||||
segment->x1-0.5)),y,1,1,exception);
|
||||
- v=GetCacheViewVirtualPixels(v_view,CastDoubleToLong(ceil(
|
||||
+ v=GetCacheViewVirtualPixels(v_view,CastDoubleToSSizeT(ceil(
|
||||
segment->x2-0.5)),y,1,1,exception);
|
||||
q=QueueCacheViewAuthenticPixels(image_view,x_mid,y,1,1,exception);
|
||||
if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
|
||||
@@ -1557,10 +1557,10 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
/*
|
||||
Top pixel.
|
||||
*/
|
||||
- y=CastDoubleToLong(ceil(segment->y1-0.5));
|
||||
- u=GetCacheViewVirtualPixels(u_view,CastDoubleToLong(ceil(
|
||||
+ y=CastDoubleToSSizeT(ceil(segment->y1-0.5));
|
||||
+ u=GetCacheViewVirtualPixels(u_view,CastDoubleToSSizeT(ceil(
|
||||
segment->x1-0.5)),y,1,1,exception);
|
||||
- v=GetCacheViewVirtualPixels(v_view,CastDoubleToLong(ceil(
|
||||
+ v=GetCacheViewVirtualPixels(v_view,CastDoubleToSSizeT(ceil(
|
||||
segment->x2-0.5)),y,1,1,exception);
|
||||
q=QueueCacheViewAuthenticPixels(image_view,x_mid,y,1,1,exception);
|
||||
if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
|
||||
@@ -1583,11 +1583,11 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
/*
|
||||
Middle pixel.
|
||||
*/
|
||||
- x=CastDoubleToLong(ceil(segment->x1-0.5));
|
||||
- y=CastDoubleToLong(ceil(segment->y1-0.5));
|
||||
+ x=CastDoubleToSSizeT(ceil(segment->x1-0.5));
|
||||
+ y=CastDoubleToSSizeT(ceil(segment->y1-0.5));
|
||||
u=GetCacheViewVirtualPixels(u_view,x,y,1,1,exception);
|
||||
- x=CastDoubleToLong(ceil(segment->x2-0.5));
|
||||
- y=CastDoubleToLong(ceil(segment->y2-0.5));
|
||||
+ x=CastDoubleToSSizeT(ceil(segment->x2-0.5));
|
||||
+ y=CastDoubleToSSizeT(ceil(segment->y2-0.5));
|
||||
v=GetCacheViewVirtualPixels(v_view,x,y,1,1,exception);
|
||||
q=QueueCacheViewAuthenticPixels(image_view,x_mid,y_mid,1,1,exception);
|
||||
if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
|
||||
diff --git a/MagickWand/drawing-wand.c b/MagickWand/drawing-wand.c
|
||||
index cc1fbc640..002798ba0 100644
|
||||
--- a/MagickWand/drawing-wand.c
|
||||
+++ b/MagickWand/drawing-wand.c
|
||||
@@ -4285,10 +4285,10 @@ WandExport MagickBooleanType DrawPushPattern(DrawingWand *wand,
|
||||
x,y,width,height);
|
||||
wand->indent_depth++;
|
||||
wand->pattern_id=AcquireString(pattern_id);
|
||||
- wand->pattern_bounds.x=CastDoubleToLong(ceil(x-0.5));
|
||||
- wand->pattern_bounds.y=CastDoubleToLong(ceil(y-0.5));
|
||||
- wand->pattern_bounds.width=(size_t) CastDoubleToLong(floor(width+0.5));
|
||||
- wand->pattern_bounds.height=(size_t) CastDoubleToLong(floor(height+0.5));
|
||||
+ wand->pattern_bounds.x=CastDoubleToSSizeT(ceil(x-0.5));
|
||||
+ wand->pattern_bounds.y=CastDoubleToSSizeT(ceil(y-0.5));
|
||||
+ wand->pattern_bounds.width=(size_t) CastDoubleToSSizeT(floor(width+0.5));
|
||||
+ wand->pattern_bounds.height=(size_t) CastDoubleToSSizeT(floor(height+0.5));
|
||||
wand->pattern_offset=wand->mvg_length;
|
||||
return(MagickTrue);
|
||||
}
|
||||
diff --git a/MagickWand/studio.h b/MagickWand/studio.h
|
||||
index 3dcb4d304..4daf7e894 100644
|
||||
--- a/MagickWand/studio.h
|
||||
+++ b/MagickWand/studio.h
|
||||
@@ -305,8 +305,6 @@ extern int vsnprintf(char *,size_t,const char *,va_list);
|
||||
/*
|
||||
Magick defines.
|
||||
*/
|
||||
-#define MAGICK_SSIZE_MAX (SSIZE_MAX)
|
||||
-#define MAGICK_SSIZE_MIN (-(SSIZE_MAX)-1)
|
||||
#if defined(_MSC_VER)
|
||||
# define DisableMSCWarning(nr) __pragma(warning(push)) \
|
||||
__pragma(warning(disable:nr))
|
||||
diff --git a/coders/histogram.c b/coders/histogram.c
|
||||
index 0df364c12..15ee9772d 100644
|
||||
--- a/coders/histogram.c
|
||||
+++ b/coders/histogram.c
|
||||
@@ -295,7 +295,7 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
|
||||
break;
|
||||
if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
|
||||
{
|
||||
- y=CastDoubleToLong(ceil((double) histogram_image->rows-scale*
|
||||
+ y=CastDoubleToSSizeT(ceil((double) histogram_image->rows-scale*
|
||||
histogram[x].red-0.5));
|
||||
r=q+y*GetPixelChannels(histogram_image);
|
||||
for ( ; y < (ssize_t) histogram_image->rows; y++)
|
||||
@@ -306,7 +306,7 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
|
||||
}
|
||||
if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
|
||||
{
|
||||
- y=CastDoubleToLong(ceil((double) histogram_image->rows-scale*
|
||||
+ y=CastDoubleToSSizeT(ceil((double) histogram_image->rows-scale*
|
||||
histogram[x].green-0.5));
|
||||
r=q+y*GetPixelChannels(histogram_image);
|
||||
for ( ; y < (ssize_t) histogram_image->rows; y++)
|
||||
@@ -317,7 +317,7 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
|
||||
}
|
||||
if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
|
||||
{
|
||||
- y=CastDoubleToLong(ceil((double) histogram_image->rows-scale*
|
||||
+ y=CastDoubleToSSizeT(ceil((double) histogram_image->rows-scale*
|
||||
histogram[x].blue-0.5));
|
||||
r=q+y*GetPixelChannels(histogram_image);
|
||||
for ( ; y < (ssize_t) histogram_image->rows; y++)
|
||||
diff --git a/coders/jpeg.c b/coders/jpeg.c
|
||||
index db385358b..d779644ab 100644
|
||||
--- a/coders/jpeg.c
|
||||
+++ b/coders/jpeg.c
|
||||
@@ -2325,7 +2325,8 @@ static MagickBooleanType WriteJPEGImage_(const ImageInfo *image_info,
|
||||
if (image->debug != MagickFalse)
|
||||
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
|
||||
"Image resolution: %.20g,%.20g",image->resolution.x,image->resolution.y);
|
||||
- if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0))
|
||||
+ if ((image->resolution.x >= 0) && (image->resolution.x < (double) SHRT_MAX) &&
|
||||
+ (image->resolution.y >= 0) && (image->resolution.y < (double) SHRT_MAX))
|
||||
{
|
||||
/*
|
||||
Set image resolution.
|
||||
diff --git a/coders/png.c b/coders/png.c
|
||||
index e730edb03..6f88e9cdc 100644
|
||||
--- a/coders/png.c
|
||||
+++ b/coders/png.c
|
||||
@@ -10020,23 +10020,23 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
|
||||
{
|
||||
ping_pHYs_unit_type=PNG_RESOLUTION_METER;
|
||||
ping_pHYs_x_resolution=
|
||||
- (png_uint_32) ((100.0*image->resolution.x+0.5)/2.54);
|
||||
+ (png_uint_32) CastDoubleToSizeT((100.0*image->resolution.x+0.5)/2.54);
|
||||
ping_pHYs_y_resolution=
|
||||
- (png_uint_32) ((100.0*image->resolution.y+0.5)/2.54);
|
||||
+ (png_uint_32) CastDoubleToSizeT((100.0*image->resolution.y+0.5)/2.54);
|
||||
}
|
||||
|
||||
else if (image->units == PixelsPerCentimeterResolution)
|
||||
{
|
||||
ping_pHYs_unit_type=PNG_RESOLUTION_METER;
|
||||
- ping_pHYs_x_resolution=(png_uint_32) (100.0*image->resolution.x+0.5);
|
||||
- ping_pHYs_y_resolution=(png_uint_32) (100.0*image->resolution.y+0.5);
|
||||
+ ping_pHYs_x_resolution=(png_uint_32) CastDoubleToSizeT(100.0*image->resolution.x+0.5);
|
||||
+ ping_pHYs_y_resolution=(png_uint_32) CastDoubleToSizeT(100.0*image->resolution.y+0.5);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ping_pHYs_unit_type=PNG_RESOLUTION_UNKNOWN;
|
||||
- ping_pHYs_x_resolution=(png_uint_32) image->resolution.x;
|
||||
- ping_pHYs_y_resolution=(png_uint_32) image->resolution.y;
|
||||
+ ping_pHYs_x_resolution=(png_uint_32) CastDoubleToSizeT(image->resolution.x);
|
||||
+ ping_pHYs_y_resolution=(png_uint_32) CastDoubleToSizeT(image->resolution.y);
|
||||
}
|
||||
|
||||
if (logging != MagickFalse)
|
||||
diff --git a/coders/tiff.c b/coders/tiff.c
|
||||
index 68a6d5b09..a0bdd6313 100644
|
||||
--- a/coders/tiff.c
|
||||
+++ b/coders/tiff.c
|
||||
@@ -1506,9 +1506,9 @@ static Image *ReadTIFFImage(const ImageInfo *image_info,
|
||||
if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position,sans) == 1) &&
|
||||
(TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position,sans) == 1))
|
||||
{
|
||||
- image->page.x=CastDoubleToLong(ceil(x_position*
|
||||
+ image->page.x=CastDoubleToSSizeT(ceil(x_position*
|
||||
image->resolution.x-0.5));
|
||||
- image->page.y=CastDoubleToLong(ceil(y_position*
|
||||
+ image->page.y=CastDoubleToSSizeT(ceil(y_position*
|
||||
image->resolution.y-0.5));
|
||||
}
|
||||
if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation,sans) == 1)
|
||||
diff --git a/coders/txt.c b/coders/txt.c
|
||||
index f8312a4fd..91323583d 100644
|
||||
--- a/coders/txt.c
|
||||
+++ b/coders/txt.c
|
||||
@@ -273,7 +273,7 @@ static Image *ReadTEXTImage(const ImageInfo *image_info,
|
||||
draw_info=DestroyDrawInfo(draw_info);
|
||||
ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
|
||||
}
|
||||
- page.y=CastDoubleToLong(ceil((double) page.y+metrics.ascent-0.5));
|
||||
+ page.y=CastDoubleToSSizeT(ceil((double) page.y+metrics.ascent-0.5));
|
||||
(void) FormatLocaleString(geometry,MagickPathExtent,"%gx%g%+g%+g",(double)
|
||||
image->columns,(double) image->rows,(double) page.x,(double) page.y);
|
||||
(void) CloneString(&draw_info->geometry,geometry);
|
||||
@@ -574,7 +574,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
|
||||
black),range);
|
||||
pixel.alpha=(MagickRealType) ScaleAnyToQuantum(CastDoubleToQuantumAny(
|
||||
alpha),range);
|
||||
- q=GetAuthenticPixels(image,CastDoubleToLong(x_offset),CastDoubleToLong(
|
||||
+ q=GetAuthenticPixels(image,CastDoubleToSSizeT(x_offset),CastDoubleToSSizeT(
|
||||
y_offset),1,1,exception);
|
||||
if (q == (Quantum *) NULL)
|
||||
{
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@ -0,0 +1,977 @@
|
||||
From 1743c78786aac899134a2b2484d802e6adde3ac4 Mon Sep 17 00:00:00 2001
|
||||
From: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
|
||||
Date: Tue, 2 Dec 2025 20:41:36 +0530
|
||||
Subject: [PATCH 17/18] ImageMagick: Add support patch 3 to fix CVE-2023-34151
|
||||
|
||||
Upstream-Status: Backport [https://github.com/ImageMagick/ImageMagick/commit/4daec2d748cb2f7540ca0d3f694fb2384b0a5601]
|
||||
|
||||
Comment: Refreshed hunk to match latest kirkstone
|
||||
|
||||
Signed-off-by: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
|
||||
---
|
||||
MagickCore/annotate.c | 8 ++---
|
||||
MagickCore/draw.c | 60 +++++++++++++++----------------
|
||||
MagickCore/effect.c | 8 ++---
|
||||
MagickCore/gem.c | 2 +-
|
||||
MagickCore/geometry.c | 18 +++++-----
|
||||
MagickCore/image-private.h | 70 +++++++++++++++++++++++++------------
|
||||
MagickCore/image.c | 20 +++++------
|
||||
MagickCore/pixel.c | 36 +++++++++----------
|
||||
MagickCore/property.c | 4 +--
|
||||
MagickCore/shear.c | 22 ++++++------
|
||||
MagickCore/transform.c | 4 +--
|
||||
MagickCore/visual-effects.c | 40 ++++++++++-----------
|
||||
MagickWand/drawing-wand.c | 8 ++---
|
||||
coders/histogram.c | 6 ++--
|
||||
coders/icon.c | 1 +
|
||||
coders/pcl.c | 4 +--
|
||||
coders/tiff.c | 4 +--
|
||||
coders/txt.c | 4 +--
|
||||
configure | 8 ++---
|
||||
19 files changed, 177 insertions(+), 150 deletions(-)
|
||||
|
||||
diff --git a/MagickCore/annotate.c b/MagickCore/annotate.c
|
||||
index 14f8d05d8..4be938be5 100644
|
||||
--- a/MagickCore/annotate.c
|
||||
+++ b/MagickCore/annotate.c
|
||||
@@ -1734,8 +1734,8 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
|
||||
|
||||
if (status == MagickFalse)
|
||||
continue;
|
||||
- x_offset=CastDoubleToSSizeT(ceil(point.x-0.5));
|
||||
- y_offset=CastDoubleToSSizeT(ceil(point.y+y-0.5));
|
||||
+ x_offset=CastDoubleToLong(ceil(point.x-0.5));
|
||||
+ y_offset=CastDoubleToLong(ceil(point.y+y-0.5));
|
||||
if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows))
|
||||
continue;
|
||||
q=(Quantum *) NULL;
|
||||
@@ -1750,7 +1750,7 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
|
||||
n=y*bitmap->bitmap.pitch;
|
||||
for (x=0; x < (ssize_t) bitmap->bitmap.width; x++, n++)
|
||||
{
|
||||
- x_offset=CastDoubleToSSizeT(ceil(point.x+x-0.5));
|
||||
+ x_offset=CastDoubleToLong(ceil(point.x+x-0.5));
|
||||
if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns))
|
||||
{
|
||||
if (q != (Quantum *) NULL)
|
||||
@@ -2102,7 +2102,7 @@ static MagickBooleanType RenderPostscript(Image *image,
|
||||
crop_info=GetImageBoundingBox(annotate_image,exception);
|
||||
crop_info.height=(size_t) ((resolution.y/DefaultResolution)*
|
||||
ExpandAffine(&draw_info->affine)*draw_info->pointsize+0.5);
|
||||
- crop_info.y=CastDoubleToSSizeT(ceil((resolution.y/DefaultResolution)*
|
||||
+ crop_info.y=CastDoubleToLong(ceil((resolution.y/DefaultResolution)*
|
||||
extent.y/8.0-0.5));
|
||||
(void) FormatLocaleString(geometry,MagickPathExtent,
|
||||
"%.20gx%.20g%+.20g%+.20g",(double) crop_info.width,(double)
|
||||
diff --git a/MagickCore/draw.c b/MagickCore/draw.c
|
||||
index 02df7d231..facea115e 100644
|
||||
--- a/MagickCore/draw.c
|
||||
+++ b/MagickCore/draw.c
|
||||
@@ -1233,8 +1233,8 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
|
||||
edge.y2=MagickMin(max.y,(double) image->rows-1.0);
|
||||
inverse_affine=InverseAffineMatrix(affine);
|
||||
GetPixelInfo(image,&zero);
|
||||
- start=CastDoubleToSSizeT(ceil(edge.y1-0.5));
|
||||
- stop=CastDoubleToSSizeT(floor(edge.y2+0.5));
|
||||
+ start=CastDoubleToLong(ceil(edge.y1-0.5));
|
||||
+ stop=CastDoubleToLong(floor(edge.y2+0.5));
|
||||
source_view=AcquireVirtualCacheView(source,exception);
|
||||
image_view=AcquireAuthenticCacheView(image,exception);
|
||||
#if defined(MAGICKCORE_OPENMP_SUPPORT)
|
||||
@@ -1267,16 +1267,16 @@ MagickExport MagickBooleanType DrawAffineImage(Image *image,
|
||||
inverse_edge=AffineEdge(source,&inverse_affine,(double) y,&edge);
|
||||
if (inverse_edge.x2 < inverse_edge.x1)
|
||||
continue;
|
||||
- q=GetCacheViewAuthenticPixels(image_view,CastDoubleToSSizeT(
|
||||
- ceil(inverse_edge.x1-0.5)),y,(size_t) CastDoubleToSSizeT(floor(
|
||||
+ q=GetCacheViewAuthenticPixels(image_view,CastDoubleToLong(
|
||||
+ ceil(inverse_edge.x1-0.5)),y,(size_t) CastDoubleToLong(floor(
|
||||
inverse_edge.x2+0.5)-ceil(inverse_edge.x1-0.5)+1),1,exception);
|
||||
if (q == (Quantum *) NULL)
|
||||
continue;
|
||||
pixel=zero;
|
||||
composite=zero;
|
||||
x_offset=0;
|
||||
- for (x=CastDoubleToSSizeT(ceil(inverse_edge.x1-0.5));
|
||||
- x <= CastDoubleToSSizeT(floor(inverse_edge.x2+0.5)); x++)
|
||||
+ for (x=CastDoubleToLong(ceil(inverse_edge.x1-0.5));
|
||||
+ x <= CastDoubleToLong(floor(inverse_edge.x2+0.5)); x++)
|
||||
{
|
||||
point.x=(double) x*inverse_affine.sx+y*inverse_affine.ry+
|
||||
inverse_affine.tx;
|
||||
@@ -2090,8 +2090,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
|
||||
case UndefinedSpread:
|
||||
case PadSpread:
|
||||
{
|
||||
- if ((x != CastDoubleToSSizeT(ceil(gradient_vector->x1-0.5))) ||
|
||||
- (y != CastDoubleToSSizeT(ceil(gradient_vector->y1-0.5))))
|
||||
+ if ((x != CastDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
|
||||
+ (y != CastDoubleToLong(ceil(gradient_vector->y1-0.5))))
|
||||
{
|
||||
offset=GetStopColorOffset(gradient,x,y);
|
||||
if (gradient->type != RadialGradient)
|
||||
@@ -2118,8 +2118,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
|
||||
}
|
||||
case ReflectSpread:
|
||||
{
|
||||
- if ((x != CastDoubleToSSizeT(ceil(gradient_vector->x1-0.5))) ||
|
||||
- (y != CastDoubleToSSizeT(ceil(gradient_vector->y1-0.5))))
|
||||
+ if ((x != CastDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
|
||||
+ (y != CastDoubleToLong(ceil(gradient_vector->y1-0.5))))
|
||||
{
|
||||
offset=GetStopColorOffset(gradient,x,y);
|
||||
if (gradient->type != RadialGradient)
|
||||
@@ -2160,8 +2160,8 @@ MagickExport MagickBooleanType DrawGradientImage(Image *image,
|
||||
|
||||
antialias=MagickFalse;
|
||||
repeat=0.0;
|
||||
- if ((x != CastDoubleToSSizeT(ceil(gradient_vector->x1-0.5))) ||
|
||||
- (y != CastDoubleToSSizeT(ceil(gradient_vector->y1-0.5))))
|
||||
+ if ((x != CastDoubleToLong(ceil(gradient_vector->x1-0.5))) ||
|
||||
+ (y != CastDoubleToLong(ceil(gradient_vector->y1-0.5))))
|
||||
{
|
||||
offset=GetStopColorOffset(gradient,x,y);
|
||||
if (gradient->type == LinearGradient)
|
||||
@@ -3457,21 +3457,21 @@ static MagickBooleanType RenderMVGContent(Image *image,
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
(void) CopyMagickString(name,token,MagickPathExtent);
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- bounds.x=CastDoubleToSSizeT(ceil(GetDrawValue(token,
|
||||
+ bounds.x=CastDoubleToLong(ceil(GetDrawValue(token,
|
||||
&next_token)-0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
if (*token == ',')
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- bounds.y=CastDoubleToSSizeT(ceil(GetDrawValue(token,
|
||||
+ bounds.y=CastDoubleToLong(ceil(GetDrawValue(token,
|
||||
&next_token)-0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
if (*token == ',')
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- bounds.width=(size_t) CastDoubleToSSizeT(floor(GetDrawValue(
|
||||
+ bounds.width=(size_t) CastDoubleToLong(floor(GetDrawValue(
|
||||
token,&next_token)+0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
@@ -3882,28 +3882,28 @@ static MagickBooleanType RenderMVGContent(Image *image,
|
||||
if (LocaleCompare("viewbox",keyword) == 0)
|
||||
{
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- graphic_context[n]->viewbox.x=CastDoubleToSSizeT(ceil(
|
||||
+ graphic_context[n]->viewbox.x=CastDoubleToLong(ceil(
|
||||
GetDrawValue(token,&next_token)-0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
if (*token == ',')
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- graphic_context[n]->viewbox.y=CastDoubleToSSizeT(ceil(
|
||||
+ graphic_context[n]->viewbox.y=CastDoubleToLong(ceil(
|
||||
GetDrawValue(token,&next_token)-0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
if (*token == ',')
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- graphic_context[n]->viewbox.width=(size_t) CastDoubleToSSizeT(
|
||||
+ graphic_context[n]->viewbox.width=(size_t) CastDoubleToLong(
|
||||
floor(GetDrawValue(token,&next_token)+0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
if (*token == ',')
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- graphic_context[n]->viewbox.height=(size_t) CastDoubleToSSizeT(
|
||||
+ graphic_context[n]->viewbox.height=(size_t) CastDoubleToLong(
|
||||
floor(GetDrawValue(token,&next_token)+0.5));
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
@@ -5017,8 +5017,8 @@ static MagickBooleanType DrawPolygonPrimitive(Image *image,
|
||||
GetPixelInfo(image,&pixel);
|
||||
for ( ; x <= stop_x; x++)
|
||||
{
|
||||
- if ((x == CastDoubleToSSizeT(ceil(primitive_info->point.x-0.5))) &&
|
||||
- (y == CastDoubleToSSizeT(ceil(primitive_info->point.y-0.5))))
|
||||
+ if ((x == CastDoubleToLong(ceil(primitive_info->point.x-0.5))) &&
|
||||
+ (y == CastDoubleToLong(ceil(primitive_info->point.y-0.5))))
|
||||
{
|
||||
GetFillColor(draw_info,x-start_x,y-start_y,&pixel,exception);
|
||||
SetPixelViaPixelInfo(image,&pixel,q);
|
||||
@@ -5164,8 +5164,8 @@ static void LogPrimitiveInfo(const PrimitiveInfo *primitive_info)
|
||||
coordinates,
|
||||
y;
|
||||
|
||||
- x=CastDoubleToSSizeT(ceil(primitive_info->point.x-0.5));
|
||||
- y=CastDoubleToSSizeT(ceil(primitive_info->point.y-0.5));
|
||||
+ x=CastDoubleToLong(ceil(primitive_info->point.x-0.5));
|
||||
+ y=CastDoubleToLong(ceil(primitive_info->point.y-0.5));
|
||||
switch (primitive_info->primitive)
|
||||
{
|
||||
case AlphaPrimitive:
|
||||
@@ -5278,8 +5278,8 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
|
||||
status&=SetImageMask(image,CompositePixelMask,draw_info->composite_mask,
|
||||
exception);
|
||||
}
|
||||
- x=CastDoubleToSSizeT(ceil(primitive_info->point.x-0.5));
|
||||
- y=CastDoubleToSSizeT(ceil(primitive_info->point.y-0.5));
|
||||
+ x=CastDoubleToLong(ceil(primitive_info->point.x-0.5));
|
||||
+ y=CastDoubleToLong(ceil(primitive_info->point.y-0.5));
|
||||
image_view=AcquireAuthenticCacheView(image,exception);
|
||||
switch (primitive_info->primitive)
|
||||
{
|
||||
@@ -5557,8 +5557,8 @@ MagickExport MagickBooleanType DrawPrimitive(Image *image,
|
||||
composite_images=DestroyImageList(composite_images);
|
||||
(void) SetImageProgressMonitor(composite_image,(MagickProgressMonitor)
|
||||
NULL,(void *) NULL);
|
||||
- x1=CastDoubleToSSizeT(ceil(primitive_info[1].point.x-0.5));
|
||||
- y1=CastDoubleToSSizeT(ceil(primitive_info[1].point.y-0.5));
|
||||
+ x1=CastDoubleToLong(ceil(primitive_info[1].point.x-0.5));
|
||||
+ y1=CastDoubleToLong(ceil(primitive_info[1].point.y-0.5));
|
||||
if (((x1 != 0L) && (x1 != (ssize_t) composite_image->columns)) ||
|
||||
((y1 != 0L) && (y1 != (ssize_t) composite_image->rows)))
|
||||
{
|
||||
@@ -6167,7 +6167,7 @@ static MagickBooleanType TraceArcPath(MVGInfo *mvg_info,const PointInfo start,
|
||||
else
|
||||
if ((theta > 0.0) && (sweep == MagickFalse))
|
||||
theta-=2.0*MagickPI;
|
||||
- arc_segments=(size_t) CastDoubleToSSizeT(ceil(fabs((double) (theta/(0.5*
|
||||
+ arc_segments=(size_t) CastDoubleToLong(ceil(fabs((double) (theta/(0.5*
|
||||
MagickPI+MagickEpsilon)))));
|
||||
status=MagickTrue;
|
||||
p=primitive_info;
|
||||
@@ -7517,7 +7517,7 @@ static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info,
|
||||
theta.q=atan2(box_q[2].y-center.y,box_q[2].x-center.x);
|
||||
if (theta.q < theta.p)
|
||||
theta.q+=2.0*MagickPI;
|
||||
- arc_segments=(size_t) CastDoubleToSSizeT(ceil((double) ((theta.
|
||||
+ arc_segments=(size_t) CastDoubleToLong(ceil((double) ((theta.
|
||||
q-theta.p)/(2.0*sqrt(PerceptibleReciprocal(mid))))));
|
||||
CheckPathExtent(MaxStrokePad,arc_segments+MaxStrokePad);
|
||||
stroke_q[q].x=box_q[1].x;
|
||||
@@ -7590,7 +7590,7 @@ static PrimitiveInfo *TraceStrokePolygon(const DrawInfo *draw_info,
|
||||
theta.q=atan2(box_p[2].y-center.y,box_p[2].x-center.x);
|
||||
if (theta.p < theta.q)
|
||||
theta.p+=2.0*MagickPI;
|
||||
- arc_segments=(size_t) CastDoubleToSSizeT(ceil((double) ((theta.p-
|
||||
+ arc_segments=(size_t) CastDoubleToLong(ceil((double) ((theta.p-
|
||||
theta.q)/(2.0*sqrt((double) (1.0/mid))))));
|
||||
CheckPathExtent(arc_segments+MaxStrokePad,MaxStrokePad);
|
||||
stroke_p[p++]=box_p[1];
|
||||
diff --git a/MagickCore/effect.c b/MagickCore/effect.c
|
||||
index a37a1999e..bfb1363f2 100644
|
||||
--- a/MagickCore/effect.c
|
||||
+++ b/MagickCore/effect.c
|
||||
@@ -288,7 +288,7 @@ MagickExport Image *AdaptiveBlurImage(const Image *image,const double radius,
|
||||
center,
|
||||
j;
|
||||
|
||||
- j=CastDoubleToSSizeT(ceil((double) width*(1.0-QuantumScale*
|
||||
+ j=CastDoubleToLong(ceil((double) width*(1.0-QuantumScale*
|
||||
GetPixelIntensity(edge_image,r))-0.5));
|
||||
if (j < 0)
|
||||
j=0;
|
||||
@@ -609,7 +609,7 @@ MagickExport Image *AdaptiveSharpenImage(const Image *image,const double radius,
|
||||
center,
|
||||
j;
|
||||
|
||||
- j=CastDoubleToSSizeT(ceil((double) width*(1.0-QuantumScale*
|
||||
+ j=CastDoubleToLong(ceil((double) width*(1.0-QuantumScale*
|
||||
GetPixelIntensity(edge_image,r))-0.5));
|
||||
if (j < 0)
|
||||
j=0;
|
||||
@@ -2402,9 +2402,9 @@ MagickExport Image *MotionBlurImage(const Image *image,const double radius,
|
||||
point.y=(double) width*cos(DegreesToRadians(angle));
|
||||
for (i=0; i < (ssize_t) width; i++)
|
||||
{
|
||||
- offset[i].x=CastDoubleToSSizeT(ceil((double) (i*point.y)/
|
||||
+ offset[i].x=CastDoubleToLong(ceil((double) (i*point.y)/
|
||||
hypot(point.x,point.y)-0.5));
|
||||
- offset[i].y=CastDoubleToSSizeT(ceil((double) (i*point.x)/
|
||||
+ offset[i].y=CastDoubleToLong(ceil((double) (i*point.x)/
|
||||
hypot(point.x,point.y)-0.5));
|
||||
}
|
||||
/*
|
||||
diff --git a/MagickCore/gem.c b/MagickCore/gem.c
|
||||
index 4eb8c3fc5..2c5911f67 100644
|
||||
--- a/MagickCore/gem.c
|
||||
+++ b/MagickCore/gem.c
|
||||
@@ -692,7 +692,7 @@ MagickPrivate void ConvertHWBToRGB(const double hue,const double whiteness,
|
||||
*blue=QuantumRange*v;
|
||||
return;
|
||||
}
|
||||
- i=CastDoubleToSSizeT(floor(6.0*hue));
|
||||
+ i=CastDoubleToLong(floor(6.0*hue));
|
||||
f=6.0*hue-i;
|
||||
if ((i & 0x01) != 0)
|
||||
f=1.0-f;
|
||||
diff --git a/MagickCore/geometry.c b/MagickCore/geometry.c
|
||||
index dd46a96fc..e9a5981bd 100644
|
||||
--- a/MagickCore/geometry.c
|
||||
+++ b/MagickCore/geometry.c
|
||||
@@ -241,7 +241,7 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
|
||||
if (LocaleNCompare(p,"0x",2) == 0)
|
||||
*width=(size_t) strtol(p,&p,10);
|
||||
else
|
||||
- *width=CastDoubleToSizeT(StringToDouble(p,&p));
|
||||
+ *width=CastDoubleToUnsigned(StringToDouble(p,&p));
|
||||
}
|
||||
if (p != q)
|
||||
flags|=WidthValue;
|
||||
@@ -260,7 +260,7 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
|
||||
*/
|
||||
q=p;
|
||||
if (height != (size_t *) NULL)
|
||||
- *height=CastDoubleToSizeT(StringToDouble(p,&p));
|
||||
+ *height=CastDoubleToUnsigned(StringToDouble(p,&p));
|
||||
if (p != q)
|
||||
flags|=HeightValue;
|
||||
}
|
||||
@@ -279,7 +279,7 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
|
||||
}
|
||||
q=p;
|
||||
if (x != (ssize_t *) NULL)
|
||||
- *x=CastDoubleToSSizeT(StringToDouble(p,&p));
|
||||
+ *x=CastDoubleToLong(StringToDouble(p,&p));
|
||||
if (p != q)
|
||||
{
|
||||
flags|=XValue;
|
||||
@@ -300,7 +300,7 @@ MagickExport MagickStatusType GetGeometry(const char *geometry,ssize_t *x,
|
||||
}
|
||||
q=p;
|
||||
if (y != (ssize_t *) NULL)
|
||||
- *y=CastDoubleToSSizeT(StringToDouble(p,&p));
|
||||
+ *y=CastDoubleToLong(StringToDouble(p,&p));
|
||||
if (p != q)
|
||||
{
|
||||
flags|=YValue;
|
||||
@@ -1285,8 +1285,8 @@ MagickExport MagickStatusType ParseGravityGeometry(const Image *image,
|
||||
scale.y=geometry_info.sigma;
|
||||
if ((status & SigmaValue) == 0)
|
||||
scale.y=scale.x;
|
||||
- region_info->width=CastDoubleToSizeT(scale.x*image->columns/100.0);
|
||||
- region_info->height=CastDoubleToSizeT(scale.y*image->rows/100.0);
|
||||
+ region_info->width=CastDoubleToUnsigned(scale.x*image->columns/100.0);
|
||||
+ region_info->height=CastDoubleToUnsigned(scale.y*image->rows/100.0);
|
||||
}
|
||||
if ((flags & AspectRatioValue) != 0)
|
||||
{
|
||||
@@ -1308,12 +1308,12 @@ MagickExport MagickStatusType ParseGravityGeometry(const Image *image,
|
||||
if (geometry_ratio >= image_ratio)
|
||||
{
|
||||
region_info->width=image->columns;
|
||||
- region_info->height=CastDoubleToSizeT((double) image->rows*image_ratio/
|
||||
+ region_info->height=CastDoubleToUnsigned((double) image->rows*image_ratio/
|
||||
geometry_ratio);
|
||||
}
|
||||
else
|
||||
{
|
||||
- region_info->width=CastDoubleToSizeT((double) image->columns*
|
||||
+ region_info->width=CastDoubleToUnsigned((double) image->columns*
|
||||
geometry_ratio/image_ratio);
|
||||
region_info->height=image->rows;
|
||||
}
|
||||
@@ -1450,7 +1450,7 @@ MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,ssize_t *x,
|
||||
}
|
||||
else
|
||||
{
|
||||
- *width=CastDoubleToSizeT(PerceptibleReciprocal(
|
||||
+ *width=CastDoubleToUnsigned(PerceptibleReciprocal(
|
||||
image_ratio)*former_width*geometry_ratio);
|
||||
*height=former_height;
|
||||
}
|
||||
diff --git a/MagickCore/image-private.h b/MagickCore/image-private.h
|
||||
index 694c19d54..8ce0208d5 100644
|
||||
--- a/MagickCore/image-private.h
|
||||
+++ b/MagickCore/image-private.h
|
||||
@@ -53,40 +53,66 @@ extern "C" {
|
||||
#define UndefinedCompressionQuality 0UL
|
||||
#define UndefinedTicksPerSecond 100L
|
||||
|
||||
-static inline QuantumAny CastDoubleToQuantumAny(const double x)
|
||||
+static inline ssize_t CastDoubleToLong(const double x)
|
||||
{
|
||||
if (IsNaN(x) != 0)
|
||||
- return(0);
|
||||
- if (x > ((double) ((QuantumAny) ~0)))
|
||||
- return((QuantumAny) ~0);
|
||||
- if (x < 0.0)
|
||||
- return(0.0);
|
||||
- return((QuantumAny) (x+0.5));
|
||||
+ {
|
||||
+ errno=ERANGE;
|
||||
+ return(0);
|
||||
+ }
|
||||
+ if (floor(x) > ((double) MAGICK_SSIZE_MAX-1))
|
||||
+ {
|
||||
+ errno=ERANGE;
|
||||
+ return((ssize_t) MAGICK_SSIZE_MAX);
|
||||
+ }
|
||||
+ if (ceil(x) < ((double) MAGICK_SSIZE_MIN+1))
|
||||
+ {
|
||||
+ errno=ERANGE;
|
||||
+ return((ssize_t) MAGICK_SSIZE_MIN);
|
||||
+ }
|
||||
+ return((ssize_t) x);
|
||||
}
|
||||
|
||||
-static inline size_t CastDoubleToSizeT(const double x)
|
||||
+static inline QuantumAny CastDoubleToQuantumAny(const double x)
|
||||
{
|
||||
if (IsNaN(x) != 0)
|
||||
- return(0);
|
||||
- if (x > ((double) MAGICK_SIZE_MAX+0.5))
|
||||
- return((size_t) MAGICK_SIZE_MAX);
|
||||
- return((size_t) floor(x+0.5));
|
||||
+ {
|
||||
+ errno=ERANGE;
|
||||
+ return(0);
|
||||
+ }
|
||||
+ if (x > ((double) ((QuantumAny) ~0)))
|
||||
+ {
|
||||
+ errno=ERANGE;
|
||||
+ return((QuantumAny) ~0);
|
||||
+ }
|
||||
+ if (x < 0.0)
|
||||
+ {
|
||||
+ errno=ERANGE;
|
||||
+ return((QuantumAny) 0);
|
||||
+ }
|
||||
+ return((QuantumAny) (x+0.5));
|
||||
}
|
||||
|
||||
-static inline ssize_t CastDoubleToSSizeT(const double x)
|
||||
+static inline size_t CastDoubleToUnsigned(const double x)
|
||||
{
|
||||
if (IsNaN(x) != 0)
|
||||
- return(0);
|
||||
- if (x > ((double) MAGICK_SSIZE_MAX+0.5))
|
||||
- return((ssize_t) MAGICK_SSIZE_MAX);
|
||||
- if (x < ((double) MAGICK_SSIZE_MIN-0.5))
|
||||
- return((ssize_t) MAGICK_SSIZE_MIN);
|
||||
- if (x >= 0.0)
|
||||
- return((ssize_t) floor(x+0.5));
|
||||
- return((ssize_t) ceil(x-0.5));
|
||||
+ {
|
||||
+ errno=ERANGE;
|
||||
+ return(0);
|
||||
+ }
|
||||
+ if (floor(x) > ((double) MAGICK_SSIZE_MAX-1))
|
||||
+ {
|
||||
+ errno=ERANGE;
|
||||
+ return((size_t) MAGICK_SIZE_MAX);
|
||||
+ }
|
||||
+ if (ceil(x) < 0.0)
|
||||
+ {
|
||||
+ errno=ERANGE;
|
||||
+ return(0);
|
||||
+ }
|
||||
+ return((size_t) x);
|
||||
}
|
||||
|
||||
-
|
||||
static inline double DegreesToRadians(const double degrees)
|
||||
{
|
||||
return((double) (MagickPI*degrees/180.0));
|
||||
diff --git a/MagickCore/image.c b/MagickCore/image.c
|
||||
index 7b8caa0d2..3e6fdd114 100644
|
||||
--- a/MagickCore/image.c
|
||||
+++ b/MagickCore/image.c
|
||||
@@ -282,21 +282,21 @@ MagickExport Image *AcquireImage(const ImageInfo *image_info,
|
||||
if ((flags & GreaterValue) != 0)
|
||||
{
|
||||
if ((double) image->delay > floor(geometry_info.rho+0.5))
|
||||
- image->delay=(size_t) CastDoubleToSSizeT(floor(
|
||||
+ image->delay=(size_t) CastDoubleToLong(floor(
|
||||
geometry_info.rho+0.5));
|
||||
}
|
||||
else
|
||||
if ((flags & LessValue) != 0)
|
||||
{
|
||||
if ((double) image->delay < floor(geometry_info.rho+0.5))
|
||||
- image->ticks_per_second=CastDoubleToSSizeT(floor(
|
||||
+ image->ticks_per_second=CastDoubleToLong(floor(
|
||||
geometry_info.sigma+0.5));
|
||||
}
|
||||
else
|
||||
- image->delay=(size_t) CastDoubleToSSizeT(floor(
|
||||
+ image->delay=(size_t) CastDoubleToLong(floor(
|
||||
geometry_info.rho+0.5));
|
||||
if ((flags & SigmaValue) != 0)
|
||||
- image->ticks_per_second=CastDoubleToSSizeT(floor(
|
||||
+ image->ticks_per_second=CastDoubleToLong(floor(
|
||||
geometry_info.sigma+0.5));
|
||||
}
|
||||
option=GetImageOption(image_info,"dispose");
|
||||
@@ -881,18 +881,18 @@ MagickExport Image *CloneImage(const Image *image,const size_t columns,
|
||||
scale=1.0;
|
||||
if (image->columns != 0)
|
||||
scale=(double) columns/(double) image->columns;
|
||||
- clone_image->page.width=(size_t) CastDoubleToSSizeT(floor(scale*
|
||||
+ clone_image->page.width=(size_t) CastDoubleToLong(floor(scale*
|
||||
image->page.width+0.5));
|
||||
- clone_image->page.x=CastDoubleToSSizeT(ceil(scale*image->page.x-0.5));
|
||||
- clone_image->tile_offset.x=CastDoubleToSSizeT(ceil(scale*
|
||||
+ clone_image->page.x=CastDoubleToLong(ceil(scale*image->page.x-0.5));
|
||||
+ clone_image->tile_offset.x=CastDoubleToLong(ceil(scale*
|
||||
image->tile_offset.x-0.5));
|
||||
scale=1.0;
|
||||
if (image->rows != 0)
|
||||
scale=(double) rows/(double) image->rows;
|
||||
- clone_image->page.height=(size_t) CastDoubleToSSizeT(floor(scale*
|
||||
+ clone_image->page.height=(size_t) CastDoubleToLong(floor(scale*
|
||||
image->page.height+0.5));
|
||||
- clone_image->page.y=CastDoubleToSSizeT(ceil(scale*image->page.y-0.5));
|
||||
- clone_image->tile_offset.y=CastDoubleToSSizeT(ceil(scale*
|
||||
+ clone_image->page.y=CastDoubleToLong(ceil(scale*image->page.y-0.5));
|
||||
+ clone_image->tile_offset.y=CastDoubleToLong(ceil(scale*
|
||||
image->tile_offset.y-0.5));
|
||||
clone_image->cache=ClonePixelCache(image->cache);
|
||||
if (SetImageExtent(clone_image,columns,rows,exception) == MagickFalse)
|
||||
diff --git a/MagickCore/pixel.c b/MagickCore/pixel.c
|
||||
index c2aea7c1d..5c1c5296f 100644
|
||||
--- a/MagickCore/pixel.c
|
||||
+++ b/MagickCore/pixel.c
|
||||
@@ -4515,8 +4515,8 @@ MagickExport MagickBooleanType InterpolatePixelChannel(
|
||||
status=MagickTrue;
|
||||
*pixel=0.0;
|
||||
traits=GetPixelChannelTraits(image,channel);
|
||||
- x_offset=CastDoubleToSSizeT(floor(x));
|
||||
- y_offset=CastDoubleToSSizeT(floor(y));
|
||||
+ x_offset=CastDoubleToLong(floor(x));
|
||||
+ y_offset=CastDoubleToLong(floor(y));
|
||||
interpolate=method;
|
||||
if (interpolate == UndefinedInterpolatePixel)
|
||||
interpolate=image->interpolate;
|
||||
@@ -4533,8 +4533,8 @@ MagickExport MagickBooleanType InterpolatePixelChannel(
|
||||
if (interpolate == Average9InterpolatePixel)
|
||||
{
|
||||
count=3;
|
||||
- x_offset=CastDoubleToSSizeT(floor(x+0.5)-1.0);
|
||||
- y_offset=CastDoubleToSSizeT(floor(y+0.5)-1.0);
|
||||
+ x_offset=CastDoubleToLong(floor(x+0.5)-1.0);
|
||||
+ y_offset=CastDoubleToLong(floor(y+0.5)-1.0);
|
||||
}
|
||||
else
|
||||
if (interpolate == Average16InterpolatePixel)
|
||||
@@ -4717,8 +4717,8 @@ MagickExport MagickBooleanType InterpolatePixelChannel(
|
||||
}
|
||||
case NearestInterpolatePixel:
|
||||
{
|
||||
- x_offset=CastDoubleToSSizeT(floor(x+0.5));
|
||||
- y_offset=CastDoubleToSSizeT(floor(y+0.5));
|
||||
+ x_offset=CastDoubleToLong(floor(x+0.5));
|
||||
+ y_offset=CastDoubleToLong(floor(y+0.5));
|
||||
p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset,1,1,exception);
|
||||
if (p == (const Quantum *) NULL)
|
||||
{
|
||||
@@ -4935,8 +4935,8 @@ MagickExport MagickBooleanType InterpolatePixelChannels(
|
||||
assert(source->signature == MagickCoreSignature);
|
||||
assert(source_view != (CacheView *) NULL);
|
||||
status=MagickTrue;
|
||||
- x_offset=CastDoubleToSSizeT(floor(x));
|
||||
- y_offset=CastDoubleToSSizeT(floor(y));
|
||||
+ x_offset=CastDoubleToLong(floor(x));
|
||||
+ y_offset=CastDoubleToLong(floor(y));
|
||||
interpolate=method;
|
||||
if (interpolate == UndefinedInterpolatePixel)
|
||||
interpolate=source->interpolate;
|
||||
@@ -4953,8 +4953,8 @@ MagickExport MagickBooleanType InterpolatePixelChannels(
|
||||
if (interpolate == Average9InterpolatePixel)
|
||||
{
|
||||
count=3;
|
||||
- x_offset=CastDoubleToSSizeT(floor(x+0.5)-1.0);
|
||||
- y_offset=CastDoubleToSSizeT(floor(y+0.5)-1.0);
|
||||
+ x_offset=CastDoubleToLong(floor(x+0.5)-1.0);
|
||||
+ y_offset=CastDoubleToLong(floor(y+0.5)-1.0);
|
||||
}
|
||||
else
|
||||
if (interpolate == Average16InterpolatePixel)
|
||||
@@ -5218,8 +5218,8 @@ MagickExport MagickBooleanType InterpolatePixelChannels(
|
||||
}
|
||||
case NearestInterpolatePixel:
|
||||
{
|
||||
- x_offset=CastDoubleToSSizeT(floor(x+0.5));
|
||||
- y_offset=CastDoubleToSSizeT(floor(y+0.5));
|
||||
+ x_offset=CastDoubleToLong(floor(x+0.5));
|
||||
+ y_offset=CastDoubleToLong(floor(y+0.5));
|
||||
p=GetCacheViewVirtualPixels(source_view,x_offset,y_offset,1,1,exception);
|
||||
if (p == (const Quantum *) NULL)
|
||||
{
|
||||
@@ -5502,8 +5502,8 @@ MagickExport MagickBooleanType InterpolatePixelInfo(const Image *image,
|
||||
assert(image->signature == MagickCoreSignature);
|
||||
assert(image_view != (CacheView *) NULL);
|
||||
status=MagickTrue;
|
||||
- x_offset=CastDoubleToSSizeT(floor(x));
|
||||
- y_offset=CastDoubleToSSizeT(floor(y));
|
||||
+ x_offset=CastDoubleToLong(floor(x));
|
||||
+ y_offset=CastDoubleToLong(floor(y));
|
||||
interpolate=method;
|
||||
if (interpolate == UndefinedInterpolatePixel)
|
||||
interpolate=image->interpolate;
|
||||
@@ -5522,8 +5522,8 @@ MagickExport MagickBooleanType InterpolatePixelInfo(const Image *image,
|
||||
if (interpolate == Average9InterpolatePixel)
|
||||
{
|
||||
count=3;
|
||||
- x_offset=CastDoubleToSSizeT(floor(x+0.5)-1.0);
|
||||
- y_offset=CastDoubleToSSizeT(floor(y+0.5)-1.0);
|
||||
+ x_offset=CastDoubleToLong(floor(x+0.5)-1.0);
|
||||
+ y_offset=CastDoubleToLong(floor(y+0.5)-1.0);
|
||||
}
|
||||
else if (interpolate == Average16InterpolatePixel)
|
||||
{
|
||||
@@ -5847,8 +5847,8 @@ MagickExport MagickBooleanType InterpolatePixelInfo(const Image *image,
|
||||
}
|
||||
case NearestInterpolatePixel:
|
||||
{
|
||||
- x_offset=CastDoubleToSSizeT(floor(x+0.5));
|
||||
- y_offset=CastDoubleToSSizeT(floor(y+0.5));
|
||||
+ x_offset=CastDoubleToLong(floor(x+0.5));
|
||||
+ y_offset=CastDoubleToLong(floor(y+0.5));
|
||||
p=GetCacheViewVirtualPixels(image_view,x_offset,y_offset,1,1,exception);
|
||||
if (p == (const Quantum *) NULL)
|
||||
{
|
||||
diff --git a/MagickCore/property.c b/MagickCore/property.c
|
||||
index b13fa7a17..1b42adaee 100644
|
||||
--- a/MagickCore/property.c
|
||||
+++ b/MagickCore/property.c
|
||||
@@ -4372,13 +4372,13 @@ MagickExport MagickBooleanType SetImageProperty(Image *image,
|
||||
if ((flags & LessValue) != 0)
|
||||
{
|
||||
if ((double) image->delay < floor(geometry_info.rho+0.5))
|
||||
- image->delay=CastDoubleToSSizeT(
|
||||
+ image->delay=CastDoubleToLong(
|
||||
floor(geometry_info.sigma+0.5));
|
||||
}
|
||||
else
|
||||
image->delay=(size_t) floor(geometry_info.rho+0.5);
|
||||
if ((flags & SigmaValue) != 0)
|
||||
- image->ticks_per_second=CastDoubleToSSizeT(floor(
|
||||
+ image->ticks_per_second=CastDoubleToLong(floor(
|
||||
geometry_info.sigma+0.5));
|
||||
return(MagickTrue);
|
||||
}
|
||||
diff --git a/MagickCore/shear.c b/MagickCore/shear.c
|
||||
index 62a98013e..05703ca34 100644
|
||||
--- a/MagickCore/shear.c
|
||||
+++ b/MagickCore/shear.c
|
||||
@@ -163,10 +163,10 @@ static MagickBooleanType CropToFitImage(Image **image,
|
||||
if (max.y < extent[i].y)
|
||||
max.y=extent[i].y;
|
||||
}
|
||||
- geometry.x=CastDoubleToSSizeT(ceil(min.x-0.5));
|
||||
- geometry.y=CastDoubleToSSizeT(ceil(min.y-0.5));
|
||||
- geometry.width=(size_t) CastDoubleToSSizeT(floor(max.x-min.x+0.5));
|
||||
- geometry.height=(size_t) CastDoubleToSSizeT(floor(max.y-min.y+0.5));
|
||||
+ geometry.x=CastDoubleToLong(ceil(min.x-0.5));
|
||||
+ geometry.y=CastDoubleToLong(ceil(min.y-0.5));
|
||||
+ geometry.width=(size_t) CastDoubleToLong(floor(max.x-min.x+0.5));
|
||||
+ geometry.height=(size_t) CastDoubleToLong(floor(max.y-min.y+0.5));
|
||||
page=(*image)->page;
|
||||
(void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
|
||||
crop_image=CropImage(*image,&geometry,exception);
|
||||
@@ -1217,7 +1217,7 @@ static MagickBooleanType XShearImage(Image *image,const double degrees,
|
||||
displacement*=(-1.0);
|
||||
direction=LEFT;
|
||||
}
|
||||
- step=CastDoubleToSSizeT(floor((double) displacement));
|
||||
+ step=CastDoubleToLong(floor((double) displacement));
|
||||
area=(double) (displacement-step);
|
||||
step++;
|
||||
pixel=background;
|
||||
@@ -1434,7 +1434,7 @@ static MagickBooleanType YShearImage(Image *image,const double degrees,
|
||||
displacement*=(-1.0);
|
||||
direction=UP;
|
||||
}
|
||||
- step=CastDoubleToSSizeT(floor((double) displacement));
|
||||
+ step=CastDoubleToLong(floor((double) displacement));
|
||||
area=(double) (displacement-step);
|
||||
step++;
|
||||
pixel=background;
|
||||
@@ -1617,11 +1617,11 @@ MagickExport Image *ShearImage(const Image *image,const double x_shear,
|
||||
/*
|
||||
Compute image size.
|
||||
*/
|
||||
- bounds.width=image->columns+CastDoubleToSSizeT(floor(fabs(shear.x)*
|
||||
+ bounds.width=image->columns+CastDoubleToLong(floor(fabs(shear.x)*
|
||||
image->rows+0.5));
|
||||
- bounds.x=CastDoubleToSSizeT(ceil((double) image->columns+((fabs(shear.x)*
|
||||
+ bounds.x=CastDoubleToLong(ceil((double) image->columns+((fabs(shear.x)*
|
||||
image->rows)-image->columns)/2.0-0.5));
|
||||
- bounds.y=CastDoubleToSSizeT(ceil((double) image->rows+((fabs(shear.y)*
|
||||
+ bounds.y=CastDoubleToLong(ceil((double) image->rows+((fabs(shear.y)*
|
||||
bounds.width)-image->rows)/2.0-0.5));
|
||||
/*
|
||||
Surround image with border.
|
||||
@@ -1770,9 +1770,9 @@ MagickExport Image *ShearRotateImage(const Image *image,const double degrees,
|
||||
bounds.height=(size_t) floor(fabs((double) bounds.width*shear.y)+height+0.5);
|
||||
shear_width=(size_t) floor(fabs((double) bounds.height*shear.x)+
|
||||
bounds.width+0.5);
|
||||
- bounds.x=CastDoubleToSSizeT(floor((double) ((shear_width > bounds.width) ?
|
||||
+ bounds.x=CastDoubleToLong(floor((double) ((shear_width > bounds.width) ?
|
||||
width : bounds.width-shear_width+2)/2.0+0.5));
|
||||
- bounds.y=CastDoubleToSSizeT(floor(((double) bounds.height-height+2)/2.0+0.5));
|
||||
+ bounds.y=CastDoubleToLong(floor(((double) bounds.height-height+2)/2.0+0.5));
|
||||
/*
|
||||
Surround image with a border.
|
||||
*/
|
||||
diff --git a/MagickCore/transform.c b/MagickCore/transform.c
|
||||
index 6afe0a3de..385d5eb68 100644
|
||||
--- a/MagickCore/transform.c
|
||||
+++ b/MagickCore/transform.c
|
||||
@@ -773,8 +773,8 @@ static inline ssize_t PixelRoundOffset(double x)
|
||||
Round the fraction to nearest integer.
|
||||
*/
|
||||
if ((x-floor(x)) < (ceil(x)-x))
|
||||
- return(CastDoubleToSSizeT(floor(x)));
|
||||
- return(CastDoubleToSSizeT(ceil(x)));
|
||||
+ return(CastDoubleToLong(floor(x)));
|
||||
+ return(CastDoubleToLong(ceil(x)));
|
||||
}
|
||||
|
||||
MagickExport Image *CropImageToTiles(const Image *image,
|
||||
diff --git a/MagickCore/visual-effects.c b/MagickCore/visual-effects.c
|
||||
index 069904a08..789660231 100644
|
||||
--- a/MagickCore/visual-effects.c
|
||||
+++ b/MagickCore/visual-effects.c
|
||||
@@ -1439,8 +1439,8 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
*/
|
||||
depth--;
|
||||
attenuate++;
|
||||
- x_mid=CastDoubleToSSizeT(ceil((segment->x1+segment->x2)/2-0.5));
|
||||
- y_mid=CastDoubleToSSizeT(ceil((segment->y1+segment->y2)/2-0.5));
|
||||
+ x_mid=CastDoubleToLong(ceil((segment->x1+segment->x2)/2-0.5));
|
||||
+ y_mid=CastDoubleToLong(ceil((segment->y1+segment->y2)/2-0.5));
|
||||
local_info=(*segment);
|
||||
local_info.x2=(double) x_mid;
|
||||
local_info.y2=(double) y_mid;
|
||||
@@ -1463,8 +1463,8 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
&local_info,attenuate,depth,exception);
|
||||
return(status == 0 ? MagickFalse : MagickTrue);
|
||||
}
|
||||
- x_mid=CastDoubleToSSizeT(ceil((segment->x1+segment->x2)/2-0.5));
|
||||
- y_mid=CastDoubleToSSizeT(ceil((segment->y1+segment->y2)/2-0.5));
|
||||
+ x_mid=CastDoubleToLong(ceil((segment->x1+segment->x2)/2-0.5));
|
||||
+ y_mid=CastDoubleToLong(ceil((segment->y1+segment->y2)/2-0.5));
|
||||
if ((fabs(segment->x1-x_mid) < MagickEpsilon) &&
|
||||
(fabs(segment->x2-x_mid) < MagickEpsilon) &&
|
||||
(fabs(segment->y1-y_mid) < MagickEpsilon) &&
|
||||
@@ -1481,10 +1481,10 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
/*
|
||||
Left pixel.
|
||||
*/
|
||||
- x=CastDoubleToSSizeT(ceil(segment->x1-0.5));
|
||||
- u=GetCacheViewVirtualPixels(u_view,x,CastDoubleToSSizeT(ceil(
|
||||
+ x=CastDoubleToLong(ceil(segment->x1-0.5));
|
||||
+ u=GetCacheViewVirtualPixels(u_view,x,CastDoubleToLong(ceil(
|
||||
segment->y1-0.5)),1,1,exception);
|
||||
- v=GetCacheViewVirtualPixels(v_view,x,CastDoubleToSSizeT(ceil(
|
||||
+ v=GetCacheViewVirtualPixels(v_view,x,CastDoubleToLong(ceil(
|
||||
segment->y2-0.5)),1,1,exception);
|
||||
q=QueueCacheViewAuthenticPixels(image_view,x,y_mid,1,1,exception);
|
||||
if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
|
||||
@@ -1504,10 +1504,10 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
/*
|
||||
Right pixel.
|
||||
*/
|
||||
- x=CastDoubleToSSizeT(ceil(segment->x2-0.5));
|
||||
- u=GetCacheViewVirtualPixels(u_view,x,CastDoubleToSSizeT(ceil(
|
||||
+ x=CastDoubleToLong(ceil(segment->x2-0.5));
|
||||
+ u=GetCacheViewVirtualPixels(u_view,x,CastDoubleToLong(ceil(
|
||||
segment->y1-0.5)),1,1,exception);
|
||||
- v=GetCacheViewVirtualPixels(v_view,x,CastDoubleToSSizeT(ceil(
|
||||
+ v=GetCacheViewVirtualPixels(v_view,x,CastDoubleToLong(ceil(
|
||||
segment->y2-0.5)),1,1,exception);
|
||||
q=QueueCacheViewAuthenticPixels(image_view,x,y_mid,1,1,exception);
|
||||
if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
|
||||
@@ -1533,10 +1533,10 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
/*
|
||||
Bottom pixel.
|
||||
*/
|
||||
- y=CastDoubleToSSizeT(ceil(segment->y2-0.5));
|
||||
- u=GetCacheViewVirtualPixels(u_view,CastDoubleToSSizeT(ceil(
|
||||
+ y=CastDoubleToLong(ceil(segment->y2-0.5));
|
||||
+ u=GetCacheViewVirtualPixels(u_view,CastDoubleToLong(ceil(
|
||||
segment->x1-0.5)),y,1,1,exception);
|
||||
- v=GetCacheViewVirtualPixels(v_view,CastDoubleToSSizeT(ceil(
|
||||
+ v=GetCacheViewVirtualPixels(v_view,CastDoubleToLong(ceil(
|
||||
segment->x2-0.5)),y,1,1,exception);
|
||||
q=QueueCacheViewAuthenticPixels(image_view,x_mid,y,1,1,exception);
|
||||
if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
|
||||
@@ -1557,10 +1557,10 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
/*
|
||||
Top pixel.
|
||||
*/
|
||||
- y=CastDoubleToSSizeT(ceil(segment->y1-0.5));
|
||||
- u=GetCacheViewVirtualPixels(u_view,CastDoubleToSSizeT(ceil(
|
||||
+ y=CastDoubleToLong(ceil(segment->y1-0.5));
|
||||
+ u=GetCacheViewVirtualPixels(u_view,CastDoubleToLong(ceil(
|
||||
segment->x1-0.5)),y,1,1,exception);
|
||||
- v=GetCacheViewVirtualPixels(v_view,CastDoubleToSSizeT(ceil(
|
||||
+ v=GetCacheViewVirtualPixels(v_view,CastDoubleToLong(ceil(
|
||||
segment->x2-0.5)),y,1,1,exception);
|
||||
q=QueueCacheViewAuthenticPixels(image_view,x_mid,y,1,1,exception);
|
||||
if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
|
||||
@@ -1583,11 +1583,11 @@ static MagickBooleanType PlasmaImageProxy(Image *image,CacheView *image_view,
|
||||
/*
|
||||
Middle pixel.
|
||||
*/
|
||||
- x=CastDoubleToSSizeT(ceil(segment->x1-0.5));
|
||||
- y=CastDoubleToSSizeT(ceil(segment->y1-0.5));
|
||||
+ x=CastDoubleToLong(ceil(segment->x1-0.5));
|
||||
+ y=CastDoubleToLong(ceil(segment->y1-0.5));
|
||||
u=GetCacheViewVirtualPixels(u_view,x,y,1,1,exception);
|
||||
- x=CastDoubleToSSizeT(ceil(segment->x2-0.5));
|
||||
- y=CastDoubleToSSizeT(ceil(segment->y2-0.5));
|
||||
+ x=CastDoubleToLong(ceil(segment->x2-0.5));
|
||||
+ y=CastDoubleToLong(ceil(segment->y2-0.5));
|
||||
v=GetCacheViewVirtualPixels(v_view,x,y,1,1,exception);
|
||||
q=QueueCacheViewAuthenticPixels(image_view,x_mid,y_mid,1,1,exception);
|
||||
if ((u == (const Quantum *) NULL) || (v == (const Quantum *) NULL) ||
|
||||
diff --git a/MagickWand/drawing-wand.c b/MagickWand/drawing-wand.c
|
||||
index 002798ba0..cc1fbc640 100644
|
||||
--- a/MagickWand/drawing-wand.c
|
||||
+++ b/MagickWand/drawing-wand.c
|
||||
@@ -4285,10 +4285,10 @@ WandExport MagickBooleanType DrawPushPattern(DrawingWand *wand,
|
||||
x,y,width,height);
|
||||
wand->indent_depth++;
|
||||
wand->pattern_id=AcquireString(pattern_id);
|
||||
- wand->pattern_bounds.x=CastDoubleToSSizeT(ceil(x-0.5));
|
||||
- wand->pattern_bounds.y=CastDoubleToSSizeT(ceil(y-0.5));
|
||||
- wand->pattern_bounds.width=(size_t) CastDoubleToSSizeT(floor(width+0.5));
|
||||
- wand->pattern_bounds.height=(size_t) CastDoubleToSSizeT(floor(height+0.5));
|
||||
+ wand->pattern_bounds.x=CastDoubleToLong(ceil(x-0.5));
|
||||
+ wand->pattern_bounds.y=CastDoubleToLong(ceil(y-0.5));
|
||||
+ wand->pattern_bounds.width=(size_t) CastDoubleToLong(floor(width+0.5));
|
||||
+ wand->pattern_bounds.height=(size_t) CastDoubleToLong(floor(height+0.5));
|
||||
wand->pattern_offset=wand->mvg_length;
|
||||
return(MagickTrue);
|
||||
}
|
||||
diff --git a/coders/histogram.c b/coders/histogram.c
|
||||
index 15ee9772d..0df364c12 100644
|
||||
--- a/coders/histogram.c
|
||||
+++ b/coders/histogram.c
|
||||
@@ -295,7 +295,7 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
|
||||
break;
|
||||
if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
|
||||
{
|
||||
- y=CastDoubleToSSizeT(ceil((double) histogram_image->rows-scale*
|
||||
+ y=CastDoubleToLong(ceil((double) histogram_image->rows-scale*
|
||||
histogram[x].red-0.5));
|
||||
r=q+y*GetPixelChannels(histogram_image);
|
||||
for ( ; y < (ssize_t) histogram_image->rows; y++)
|
||||
@@ -306,7 +306,7 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
|
||||
}
|
||||
if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
|
||||
{
|
||||
- y=CastDoubleToSSizeT(ceil((double) histogram_image->rows-scale*
|
||||
+ y=CastDoubleToLong(ceil((double) histogram_image->rows-scale*
|
||||
histogram[x].green-0.5));
|
||||
r=q+y*GetPixelChannels(histogram_image);
|
||||
for ( ; y < (ssize_t) histogram_image->rows; y++)
|
||||
@@ -317,7 +317,7 @@ static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
|
||||
}
|
||||
if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
|
||||
{
|
||||
- y=CastDoubleToSSizeT(ceil((double) histogram_image->rows-scale*
|
||||
+ y=CastDoubleToLong(ceil((double) histogram_image->rows-scale*
|
||||
histogram[x].blue-0.5));
|
||||
r=q+y*GetPixelChannels(histogram_image);
|
||||
for ( ; y < (ssize_t) histogram_image->rows; y++)
|
||||
diff --git a/coders/icon.c b/coders/icon.c
|
||||
index 2ccbc82b1..f54225ff9 100644
|
||||
--- a/coders/icon.c
|
||||
+++ b/coders/icon.c
|
||||
@@ -227,6 +227,7 @@ static Image *ReadICONImage(const ImageInfo *image_info,
|
||||
image=DestroyImageList(image);
|
||||
return((Image *) NULL);
|
||||
}
|
||||
+ (void) memset(&icon_file,0,sizeof(icon_file));
|
||||
icon_file.reserved=(short) ReadBlobLSBShort(image);
|
||||
icon_file.resource_type=(short) ReadBlobLSBShort(image);
|
||||
icon_file.count=(short) ReadBlobLSBShort(image);
|
||||
diff --git a/coders/pcl.c b/coders/pcl.c
|
||||
index 8197a0c39..8056ae0c9 100644
|
||||
--- a/coders/pcl.c
|
||||
+++ b/coders/pcl.c
|
||||
@@ -294,8 +294,8 @@ static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)
|
||||
/*
|
||||
Set PCL render geometry.
|
||||
*/
|
||||
- width=(size_t) floor(bounds.x2-bounds.x1+0.5);
|
||||
- height=(size_t) floor(bounds.y2-bounds.y1+0.5);
|
||||
+ width=(size_t) CastDoubleToLong(floor(bounds.x2-bounds.x1+0.5));
|
||||
+ height=(size_t) CastDoubleToLong(floor(bounds.y2-bounds.y1+0.5));
|
||||
if (width > page.width)
|
||||
page.width=width;
|
||||
if (height > page.height)
|
||||
diff --git a/coders/tiff.c b/coders/tiff.c
|
||||
index a0bdd6313..68a6d5b09 100644
|
||||
--- a/coders/tiff.c
|
||||
+++ b/coders/tiff.c
|
||||
@@ -1506,9 +1506,9 @@ static Image *ReadTIFFImage(const ImageInfo *image_info,
|
||||
if ((TIFFGetFieldDefaulted(tiff,TIFFTAG_XPOSITION,&x_position,sans) == 1) &&
|
||||
(TIFFGetFieldDefaulted(tiff,TIFFTAG_YPOSITION,&y_position,sans) == 1))
|
||||
{
|
||||
- image->page.x=CastDoubleToSSizeT(ceil(x_position*
|
||||
+ image->page.x=CastDoubleToLong(ceil(x_position*
|
||||
image->resolution.x-0.5));
|
||||
- image->page.y=CastDoubleToSSizeT(ceil(y_position*
|
||||
+ image->page.y=CastDoubleToLong(ceil(y_position*
|
||||
image->resolution.y-0.5));
|
||||
}
|
||||
if (TIFFGetFieldDefaulted(tiff,TIFFTAG_ORIENTATION,&orientation,sans) == 1)
|
||||
diff --git a/coders/txt.c b/coders/txt.c
|
||||
index 91323583d..f8312a4fd 100644
|
||||
--- a/coders/txt.c
|
||||
+++ b/coders/txt.c
|
||||
@@ -273,7 +273,7 @@ static Image *ReadTEXTImage(const ImageInfo *image_info,
|
||||
draw_info=DestroyDrawInfo(draw_info);
|
||||
ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
|
||||
}
|
||||
- page.y=CastDoubleToSSizeT(ceil((double) page.y+metrics.ascent-0.5));
|
||||
+ page.y=CastDoubleToLong(ceil((double) page.y+metrics.ascent-0.5));
|
||||
(void) FormatLocaleString(geometry,MagickPathExtent,"%gx%g%+g%+g",(double)
|
||||
image->columns,(double) image->rows,(double) page.x,(double) page.y);
|
||||
(void) CloneString(&draw_info->geometry,geometry);
|
||||
@@ -574,7 +574,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
|
||||
black),range);
|
||||
pixel.alpha=(MagickRealType) ScaleAnyToQuantum(CastDoubleToQuantumAny(
|
||||
alpha),range);
|
||||
- q=GetAuthenticPixels(image,CastDoubleToSSizeT(x_offset),CastDoubleToSSizeT(
|
||||
+ q=GetAuthenticPixels(image,CastDoubleToLong(x_offset),CastDoubleToLong(
|
||||
y_offset),1,1,exception);
|
||||
if (q == (Quantum *) NULL)
|
||||
{
|
||||
diff --git a/configure b/configure
|
||||
index 0b3c67e72..85aade112 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -4552,7 +4552,7 @@ MAGICK_PATCHLEVEL_VERSION=62
|
||||
|
||||
MAGICK_VERSION=7.0.10-62
|
||||
|
||||
-MAGICK_GIT_REVISION=18417:ff04e172d:20210207
|
||||
+MAGICK_GIT_REVISION=fecfed4d0:20230414
|
||||
|
||||
|
||||
# Substitute library versioning
|
||||
@@ -25948,9 +25948,9 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
- int f(int x){return 1;}
|
||||
- int f(char x){return 1;}
|
||||
- int f(bool x){return 1;}
|
||||
+ int f(int x){return x;}
|
||||
+ int f(char x){return x == '\1' ? 1 : 0;}
|
||||
+ int f(bool x){return x ? 1 : 0;}
|
||||
int
|
||||
main ()
|
||||
{
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@ -0,0 +1,314 @@
|
||||
From 3fb6d745e0817dd4c7ec31e929bfade8a7506bf5 Mon Sep 17 00:00:00 2001
|
||||
From: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
|
||||
Date: Tue, 2 Dec 2025 21:55:47 +0530
|
||||
Subject: [PATCH 18/18] ImageMagick: Fix CVE-2023-34151
|
||||
|
||||
CVE: CVE-2023-34151
|
||||
|
||||
Upstream-Status: Backport [https://github.com/ImageMagick/ImageMagick/commit/3d6d98d8a2be30d74172ab43b5b8e874d2deb158]
|
||||
|
||||
Comment: Refreshed hunk to match latest kirkstone
|
||||
|
||||
Signed-off-by: Divyanshu Rathore <Divyanshu.Rathore@bmwtechworks.in>
|
||||
---
|
||||
MagickCore/annotate.c | 4 ++--
|
||||
MagickCore/draw.c | 2 +-
|
||||
MagickCore/geometry.c | 4 ++--
|
||||
MagickCore/shear.c | 6 +++---
|
||||
MagickCore/visual-effects.c | 4 ++--
|
||||
coders/caption.c | 10 +++++-----
|
||||
coders/label.c | 10 +++++-----
|
||||
coders/pcl.c | 4 ++--
|
||||
coders/pdf.c | 4 ++--
|
||||
coders/png.c | 12 ++++++------
|
||||
coders/ps.c | 4 ++--
|
||||
coders/ps2.c | 4 ++--
|
||||
coders/ps3.c | 4 ++--
|
||||
coders/svg.c | 4 ++--
|
||||
14 files changed, 38 insertions(+), 38 deletions(-)
|
||||
|
||||
diff --git a/MagickCore/annotate.c b/MagickCore/annotate.c
|
||||
index 4be938be5..3e8f3aa1b 100644
|
||||
--- a/MagickCore/annotate.c
|
||||
+++ b/MagickCore/annotate.c
|
||||
@@ -336,7 +336,7 @@ MagickExport MagickBooleanType AnnotateImage(Image *image,
|
||||
(void) CloneString(&annotate->text,textlist[i]);
|
||||
if ((metrics.width == 0) || (annotate->gravity != NorthWestGravity))
|
||||
(void) GetTypeMetrics(image,annotate,&metrics,exception);
|
||||
- height=(size_t) floor(metrics.ascent-metrics.descent+0.5);
|
||||
+ height=CastDoubleToUnsigned(metrics.ascent-metrics.descent+0.5);
|
||||
if (height == 0)
|
||||
height=draw_info->pointsize;
|
||||
height+=(size_t) floor(draw_info->interline_spacing+0.5);
|
||||
@@ -626,7 +626,7 @@ MagickExport ssize_t FormatMagickCaption(Image *image,DrawInfo *draw_info,
|
||||
status=GetTypeMetrics(image,draw_info,metrics,exception);
|
||||
if (status == MagickFalse)
|
||||
break;
|
||||
- width=(size_t) floor(metrics->width+draw_info->stroke_width+0.5);
|
||||
+ width=CastDoubleToUnsigned(metrics->width+draw_info->stroke_width+0.5);
|
||||
if (width <= image->columns)
|
||||
continue;
|
||||
if (s != (char *) NULL)
|
||||
diff --git a/MagickCore/draw.c b/MagickCore/draw.c
|
||||
index facea115e..54286130a 100644
|
||||
--- a/MagickCore/draw.c
|
||||
+++ b/MagickCore/draw.c
|
||||
@@ -3478,7 +3478,7 @@ static MagickBooleanType RenderMVGContent(Image *image,
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
if (*token == ',')
|
||||
(void) GetNextToken(q,&q,extent,token);
|
||||
- bounds.height=(size_t) floor(GetDrawValue(token,&next_token)+
|
||||
+ bounds.height=CastDoubleToUnsigned(GetDrawValue(token,&next_token)+
|
||||
0.5);
|
||||
if (token == next_token)
|
||||
ThrowPointExpectedException(token,exception);
|
||||
diff --git a/MagickCore/geometry.c b/MagickCore/geometry.c
|
||||
index e9a5981bd..885493b94 100644
|
||||
--- a/MagickCore/geometry.c
|
||||
+++ b/MagickCore/geometry.c
|
||||
@@ -1424,8 +1424,8 @@ MagickExport MagickStatusType ParseMetaGeometry(const char *geometry,ssize_t *x,
|
||||
scale.y=geometry_info.sigma;
|
||||
if ((percent_flags & SigmaValue) == 0)
|
||||
scale.y=scale.x;
|
||||
- *width=(size_t) floor(scale.x*former_width/100.0+0.5);
|
||||
- *height=(size_t) floor(scale.y*former_height/100.0+0.5);
|
||||
+ *width=CastDoubleToUnsigned (scale.x*former_width/100.0+0.5);
|
||||
+ *height=CastDoubleToUnsigned (scale.y*former_height/100.0+0.5);
|
||||
former_width=(*width);
|
||||
former_height=(*height);
|
||||
}
|
||||
diff --git a/MagickCore/shear.c b/MagickCore/shear.c
|
||||
index 05703ca34..a4c75431f 100644
|
||||
--- a/MagickCore/shear.c
|
||||
+++ b/MagickCore/shear.c
|
||||
@@ -1766,9 +1766,9 @@ MagickExport Image *ShearRotateImage(const Image *image,const double degrees,
|
||||
*/
|
||||
width=integral_image->columns;
|
||||
height=integral_image->rows;
|
||||
- bounds.width=(size_t) floor(fabs((double) height*shear.x)+width+0.5);
|
||||
- bounds.height=(size_t) floor(fabs((double) bounds.width*shear.y)+height+0.5);
|
||||
- shear_width=(size_t) floor(fabs((double) bounds.height*shear.x)+
|
||||
+ bounds.width=CastDoubleToUnsigned(fabs((double) height*shear.x)+width+0.5);
|
||||
+ bounds.height=CastDoubleToUnsigned(fabs((double) bounds.width*shear.y)+height+0.5);
|
||||
+ shear_width=CastDoubleToUnsigned(fabs((double) bounds.height*shear.x)+
|
||||
bounds.width+0.5);
|
||||
bounds.x=CastDoubleToLong(floor((double) ((shear_width > bounds.width) ?
|
||||
width : bounds.width-shear_width+2)/2.0+0.5));
|
||||
diff --git a/MagickCore/visual-effects.c b/MagickCore/visual-effects.c
|
||||
index 789660231..3f5a5ee5e 100644
|
||||
--- a/MagickCore/visual-effects.c
|
||||
+++ b/MagickCore/visual-effects.c
|
||||
@@ -2062,8 +2062,8 @@ MagickExport Image *ShadowImage(const Image *image,const double alpha,
|
||||
(void) SetImageColorspace(clone_image,sRGBColorspace,exception);
|
||||
(void) SetImageVirtualPixelMethod(clone_image,EdgeVirtualPixelMethod,
|
||||
exception);
|
||||
- border_info.width=(size_t) floor(2.0*sigma+0.5);
|
||||
- border_info.height=(size_t) floor(2.0*sigma+0.5);
|
||||
+ border_info.width=CastDoubleToUnsigned(2.0*sigma+0.5);
|
||||
+ border_info.height=CastDoubleToUnsigned(2.0*sigma+0.5);
|
||||
border_info.x=0;
|
||||
border_info.y=0;
|
||||
(void) QueryColorCompliance("none",AllCompliance,&clone_image->border_color,
|
||||
diff --git a/coders/caption.c b/coders/caption.c
|
||||
index 67a3fb48c..cff07fd10 100644
|
||||
--- a/coders/caption.c
|
||||
+++ b/coders/caption.c
|
||||
@@ -155,7 +155,7 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info,
|
||||
return(DestroyImageList(image));
|
||||
(void) SetImageProperty(image,"caption",caption,exception);
|
||||
draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
|
||||
- width=(size_t) floor(draw_info->pointsize*strlen(caption)+0.5);
|
||||
+ width=CastDoubleToUnsigned(draw_info->pointsize*strlen(caption)+0.5);
|
||||
if (AcquireMagickResource(WidthResource,width) == MagickFalse)
|
||||
{
|
||||
caption=DestroyString(caption);
|
||||
@@ -249,8 +249,8 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info,
|
||||
status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
|
||||
if (status == MagickFalse)
|
||||
break;
|
||||
- width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5);
|
||||
- height=(size_t) floor(metrics.height+draw_info->interline_spacing+
|
||||
+ width=CastDoubleToUnsigned(metrics.width+draw_info->stroke_width+0.5);
|
||||
+ height=CastDoubleToUnsigned(metrics.height+draw_info->interline_spacing+
|
||||
draw_info->stroke_width+0.5);
|
||||
if ((image->columns != 0) && (image->rows != 0))
|
||||
{
|
||||
@@ -279,8 +279,8 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info,
|
||||
status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
|
||||
if (status == MagickFalse)
|
||||
break;
|
||||
- width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5);
|
||||
- height=(size_t) floor(metrics.height+draw_info->interline_spacing+
|
||||
+ width=CastDoubleToUnsigned(metrics.width+draw_info->stroke_width+0.5);
|
||||
+ height=CastDoubleToUnsigned(metrics.height+draw_info->interline_spacing+
|
||||
draw_info->stroke_width+0.5);
|
||||
if ((image->columns != 0) && (image->rows != 0))
|
||||
{
|
||||
diff --git a/coders/label.c b/coders/label.c
|
||||
index b6c25036f..cd76961f7 100644
|
||||
--- a/coders/label.c
|
||||
+++ b/coders/label.c
|
||||
@@ -135,7 +135,7 @@ static Image *ReadLABELImage(const ImageInfo *image_info,
|
||||
return(DestroyImageList(image));
|
||||
(void) SetImageProperty(image,"label",label,exception);
|
||||
draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
|
||||
- width=(size_t) floor(draw_info->pointsize*strlen(label)+0.5);
|
||||
+ width=CastDoubleToUnsigned(draw_info->pointsize*strlen(label)+0.5);
|
||||
if (AcquireMagickResource(WidthResource,width) == MagickFalse)
|
||||
{
|
||||
label=DestroyString(label);
|
||||
@@ -174,8 +174,8 @@ static Image *ReadLABELImage(const ImageInfo *image_info,
|
||||
status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
|
||||
if (status == MagickFalse)
|
||||
break;
|
||||
- width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5);
|
||||
- height=(size_t) floor(metrics.height+draw_info->stroke_width+0.5);
|
||||
+ width=CastDoubleToUnsigned(metrics.width+draw_info->stroke_width+0.5);
|
||||
+ height=CastDoubleToUnsigned(metrics.height+draw_info->stroke_width+0.5);
|
||||
if ((image->columns != 0) && (image->rows != 0))
|
||||
{
|
||||
if ((width >= image->columns) && (height >= image->rows))
|
||||
@@ -204,8 +204,8 @@ static Image *ReadLABELImage(const ImageInfo *image_info,
|
||||
status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
|
||||
if (status == MagickFalse)
|
||||
break;
|
||||
- width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5);
|
||||
- height=(size_t) floor(metrics.height+draw_info->stroke_width+0.5);
|
||||
+ width=CastDoubleToUnsigned(metrics.width+draw_info->stroke_width+0.5);
|
||||
+ height=CastDoubleToUnsigned(metrics.height+draw_info->stroke_width+0.5);
|
||||
if ((image->columns != 0) && (image->rows != 0))
|
||||
{
|
||||
if ((width < image->columns) && (height < image->rows))
|
||||
diff --git a/coders/pcl.c b/coders/pcl.c
|
||||
index 8056ae0c9..d6b9ed75f 100644
|
||||
--- a/coders/pcl.c
|
||||
+++ b/coders/pcl.c
|
||||
@@ -333,8 +333,8 @@ static Image *ReadPCLImage(const ImageInfo *image_info,ExceptionInfo *exception)
|
||||
image->resolution.x,image->resolution.y);
|
||||
if (image_info->ping != MagickFalse)
|
||||
(void) FormatLocaleString(density,MagickPathExtent,"2.0x2.0");
|
||||
- page.width=(size_t) floor(page.width*image->resolution.x/delta.x+0.5);
|
||||
- page.height=(size_t) floor(page.height*image->resolution.y/delta.y+0.5);
|
||||
+ page.width=CastDoubleToUnsigned(page.width*image->resolution.x/delta.x+0.5);
|
||||
+ page.height=CastDoubleToUnsigned(page.height*image->resolution.y/delta.y+0.5);
|
||||
(void) FormatLocaleString(options,MagickPathExtent,"-g%.20gx%.20g ",(double)
|
||||
page.width,(double) page.height);
|
||||
image=DestroyImage(image);
|
||||
diff --git a/coders/pdf.c b/coders/pdf.c
|
||||
index 7792d417a..3e8b3c182 100644
|
||||
--- a/coders/pdf.c
|
||||
+++ b/coders/pdf.c
|
||||
@@ -1605,9 +1605,9 @@ static MagickBooleanType WritePDFImage(const ImageInfo *image_info,Image *image,
|
||||
(void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
|
||||
&geometry.width,&geometry.height);
|
||||
scale.x=(double) (geometry.width*delta.x)/resolution.x;
|
||||
- geometry.width=(size_t) floor(scale.x+0.5);
|
||||
+ geometry.width=CastDoubleToUnsigned(scale.x+0.5);
|
||||
scale.y=(double) (geometry.height*delta.y)/resolution.y;
|
||||
- geometry.height=(size_t) floor(scale.y+0.5);
|
||||
+ geometry.height=CastDoubleToUnsigned(scale.y+0.5);
|
||||
(void) ParseAbsoluteGeometry(page_geometry,&media_info);
|
||||
(void) ParseGravityGeometry(image,page_geometry,&page_info,exception);
|
||||
if (image->gravity != UndefinedGravity)
|
||||
diff --git a/coders/png.c b/coders/png.c
|
||||
index 6f88e9cdc..6dedf2849 100644
|
||||
--- a/coders/png.c
|
||||
+++ b/coders/png.c
|
||||
@@ -10020,23 +10020,23 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
|
||||
{
|
||||
ping_pHYs_unit_type=PNG_RESOLUTION_METER;
|
||||
ping_pHYs_x_resolution=
|
||||
- (png_uint_32) CastDoubleToSizeT((100.0*image->resolution.x+0.5)/2.54);
|
||||
+ (png_uint_32) CastDoubleToUnsigned((100.0*image->resolution.x+0.5)/2.54);
|
||||
ping_pHYs_y_resolution=
|
||||
- (png_uint_32) CastDoubleToSizeT((100.0*image->resolution.y+0.5)/2.54);
|
||||
+ (png_uint_32) CastDoubleToUnsigned((100.0*image->resolution.y+0.5)/2.54);
|
||||
}
|
||||
|
||||
else if (image->units == PixelsPerCentimeterResolution)
|
||||
{
|
||||
ping_pHYs_unit_type=PNG_RESOLUTION_METER;
|
||||
- ping_pHYs_x_resolution=(png_uint_32) CastDoubleToSizeT(100.0*image->resolution.x+0.5);
|
||||
- ping_pHYs_y_resolution=(png_uint_32) CastDoubleToSizeT(100.0*image->resolution.y+0.5);
|
||||
+ ping_pHYs_x_resolution=(png_uint_32) CastDoubleToUnsigned(100.0*image->resolution.x+0.5);
|
||||
+ ping_pHYs_y_resolution=(png_uint_32) CastDoubleToUnsigned(100.0*image->resolution.y+0.5);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ping_pHYs_unit_type=PNG_RESOLUTION_UNKNOWN;
|
||||
- ping_pHYs_x_resolution=(png_uint_32) CastDoubleToSizeT(image->resolution.x);
|
||||
- ping_pHYs_y_resolution=(png_uint_32) CastDoubleToSizeT(image->resolution.y);
|
||||
+ ping_pHYs_x_resolution=(png_uint_32) CastDoubleToUnsigned(image->resolution.x);
|
||||
+ ping_pHYs_y_resolution=(png_uint_32) CastDoubleToUnsigned(image->resolution.y);
|
||||
}
|
||||
|
||||
if (logging != MagickFalse)
|
||||
diff --git a/coders/ps.c b/coders/ps.c
|
||||
index 3c18e5a92..9b3f3da88 100644
|
||||
--- a/coders/ps.c
|
||||
+++ b/coders/ps.c
|
||||
@@ -1483,9 +1483,9 @@ static MagickBooleanType WritePSImage(const ImageInfo *image_info,Image *image,
|
||||
(void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
|
||||
&geometry.width,&geometry.height);
|
||||
scale.x=PerceptibleReciprocal(resolution.x)*geometry.width*delta.x;
|
||||
- geometry.width=(size_t) floor(scale.x+0.5);
|
||||
+ geometry.width=CastDoubleToUnsigned(scale.x+0.5);
|
||||
scale.y=PerceptibleReciprocal(resolution.y)*geometry.height*delta.y;
|
||||
- geometry.height=(size_t) floor(scale.y+0.5);
|
||||
+ geometry.height=CastDoubleToUnsigned(scale.y+0.5);
|
||||
(void) ParseAbsoluteGeometry(page_geometry,&media_info);
|
||||
(void) ParseGravityGeometry(image,page_geometry,&page_info,exception);
|
||||
if (image->gravity != UndefinedGravity)
|
||||
diff --git a/coders/ps2.c b/coders/ps2.c
|
||||
index 31e7f75c7..2e713c64a 100644
|
||||
--- a/coders/ps2.c
|
||||
+++ b/coders/ps2.c
|
||||
@@ -533,9 +533,9 @@ static MagickBooleanType WritePS2Image(const ImageInfo *image_info,Image *image,
|
||||
(void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
|
||||
&geometry.width,&geometry.height);
|
||||
scale.x=PerceptibleReciprocal(resolution.x)*geometry.width*delta.x;
|
||||
- geometry.width=(size_t) floor(scale.x+0.5);
|
||||
+ geometry.width=CastDoubleToUnsigned(scale.x+0.5);
|
||||
scale.y=PerceptibleReciprocal(resolution.y)*geometry.height*delta.y;
|
||||
- geometry.height=(size_t) floor(scale.y+0.5);
|
||||
+ geometry.height=CastDoubleToUnsigned(scale.y+0.5);
|
||||
(void) ParseAbsoluteGeometry(page_geometry,&media_info);
|
||||
(void) ParseGravityGeometry(image,page_geometry,&page_info,exception);
|
||||
if (image->gravity != UndefinedGravity)
|
||||
diff --git a/coders/ps3.c b/coders/ps3.c
|
||||
index 62f47c439..beb007587 100644
|
||||
--- a/coders/ps3.c
|
||||
+++ b/coders/ps3.c
|
||||
@@ -980,9 +980,9 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image,
|
||||
(void) ParseMetaGeometry(page_geometry,&geometry.x,&geometry.y,
|
||||
&geometry.width,&geometry.height);
|
||||
scale.x=PerceptibleReciprocal(resolution.x)*geometry.width*delta.x;
|
||||
- geometry.width=(size_t) floor(scale.x+0.5);
|
||||
+ geometry.width=CastDoubleToUnsigned(scale.x+0.5);
|
||||
scale.y=PerceptibleReciprocal(resolution.y)*geometry.height*delta.y;
|
||||
- geometry.height=(size_t) floor(scale.y+0.5);
|
||||
+ geometry.height=CastDoubleToUnsigned(scale.y+0.5);
|
||||
(void) ParseAbsoluteGeometry(page_geometry,&media_info);
|
||||
(void) ParseGravityGeometry(image,page_geometry,&page_info,exception);
|
||||
if (image->gravity != UndefinedGravity)
|
||||
diff --git a/coders/svg.c b/coders/svg.c
|
||||
index 8f80d83e3..5caf8afe7 100644
|
||||
--- a/coders/svg.c
|
||||
+++ b/coders/svg.c
|
||||
@@ -2520,10 +2520,10 @@ static void SVGStartElement(void *context,const xmlChar *name,
|
||||
svg_info->view_box=svg_info->bounds;
|
||||
svg_info->width=0;
|
||||
if (svg_info->bounds.width > 0.0)
|
||||
- svg_info->width=(size_t) floor(svg_info->bounds.width+0.5);
|
||||
+ svg_info->width=CastDoubleToUnsigned(svg_info->bounds.width+0.5);
|
||||
svg_info->height=0;
|
||||
if (svg_info->bounds.height > 0.0)
|
||||
- svg_info->height=(size_t) floor(svg_info->bounds.height+0.5);
|
||||
+ svg_info->height=CastDoubleToUnsigned(svg_info->bounds.height+0.5);
|
||||
(void) FormatLocaleFile(svg_info->file,"viewbox 0 0 %.20g %.20g\n",
|
||||
(double) svg_info->width,(double) svg_info->height);
|
||||
sx=PerceptibleReciprocal(svg_info->view_box.width)*svg_info->width;
|
||||
--
|
||||
2.34.1
|
||||
|
||||
@ -41,6 +41,10 @@ SRC_URI = "git://github.com/ImageMagick/ImageMagick.git;branch=main;protocol=htt
|
||||
file://0010-ImageMagick-Add-support-patch-3-to-fix-CVE-2025-5529.patch \
|
||||
file://0010-ImageMagick-Fix-CVE-2025-55298-1.patch \
|
||||
file://0010-ImageMagick-Fix-CVE-2025-55298-2.patch \
|
||||
file://0011-ImageMagick-Add-support-patch-1-to-fix-CVE-2023-3415.patch \
|
||||
file://0011-ImageMagick-Add-support-patch-2-to-fix-CVE-2023-3415.patch \
|
||||
file://0011-ImageMagick-Add-support-patch-3-to-fix-CVE-2023-3415.patch \
|
||||
file://0011-ImageMagick-Fix-CVE-2023-34151.patch \
|
||||
"
|
||||
|
||||
SRCREV = "35b4991eb0939a327f3489988c366e21068b0178"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user