diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2017-01-10 19:31:33 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2017-01-10 19:52:06 +0100 |
commit | 15837bab8ce05ead227d654f0b7ed8f6a0a431d8 (patch) | |
tree | 16685026e76e86754db93e2839842290cc220cc7 /ext/gd | |
parent | 6a9efa2d3e6180c3df23dc8b7832f17b5de6acde (diff) | |
download | php-git-15837bab8ce05ead227d654f0b7ed8f6a0a431d8.tar.gz |
Fix #73893: A hidden danger of death cycle in a function of gd
We remove the unused, but potentially dangerous functions.
Diffstat (limited to 'ext/gd')
-rw-r--r-- | ext/gd/libgd/gd.h | 2 | ||||
-rw-r--r-- | ext/gd/libgd/gd_rotate.c | 215 |
2 files changed, 0 insertions, 217 deletions
diff --git a/ext/gd/libgd/gd.h b/ext/gd/libgd/gd.h index 2eb4fd8e1c..2a554a5900 100644 --- a/ext/gd/libgd/gd.h +++ b/ext/gd/libgd/gd.h @@ -693,8 +693,6 @@ void gdImageCopyResampled(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, in gdImagePtr gdImageRotate90(gdImagePtr src, int ignoretransparent); gdImagePtr gdImageRotate180(gdImagePtr src, int ignoretransparent); gdImagePtr gdImageRotate270(gdImagePtr src, int ignoretransparent); -gdImagePtr gdImageRotate45(gdImagePtr src, double dAngle, int clrBack, int ignoretransparent); -gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent); gdImagePtr gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor); void gdImageSetBrush(gdImagePtr im, gdImagePtr brush); diff --git a/ext/gd/libgd/gd_rotate.c b/ext/gd/libgd/gd_rotate.c index e94809ae77..3ec0b5bff2 100644 --- a/ext/gd/libgd/gd_rotate.c +++ b/ext/gd/libgd/gd_rotate.c @@ -343,218 +343,3 @@ gdImagePtr gdImageRotate270 (gdImagePtr src, int ignoretransparent) return dst; } - -gdImagePtr gdImageRotate45 (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent) -{ - typedef int (*FuncPtr)(gdImagePtr, int, int); - gdImagePtr dst1,dst2,dst3; - FuncPtr f; - double dRadAngle, dSinE, dTan, dShear; - double dOffset; /* Variable skew offset */ - int u, iShear, newx, newy; - int clrBackR, clrBackG, clrBackB, clrBackA; - - /* See GEMS I for the algorithm details */ - dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */ - dSinE = sin (dRadAngle); - dTan = tan (dRadAngle / 2.0); - - newx = (int)(src->sx + src->sy * fabs(dTan)); - newy = src->sy; - - /* 1st shear */ - if (src->trueColor) { - f = gdImageGetTrueColorPixel; - } else { - f = gdImageGetPixel; - } - - dst1 = gdImageCreateTrueColor(newx, newy); - /******* Perform 1st shear (horizontal) ******/ - if (dst1 == NULL) { - return NULL; - } -#ifdef HAVE_GD_BUNDLED - dst1->alphaBlendingFlag = gdEffectReplace; -#else - gdImageAlphaBlending(dst1, 0); -#endif - if (dAngle == 0.0) { - /* Returns copy of src */ - gdImageCopy (dst1, src,0,0,0,0,src->sx,src->sy); - return dst1; - } - - gdImagePaletteCopy (dst1, src); - - if (ignoretransparent) { - if (gdImageTrueColor(src)) { - dst1->transparent = src->transparent; - } else { - - dst1->transparent = gdTrueColorAlpha(gdImageRed(src, src->transparent), gdImageBlue(src, src->transparent), gdImageGreen(src, src->transparent), 127); - } - } - - dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */ - dSinE = sin (dRadAngle); - dTan = tan (dRadAngle / 2.0); - - for (u = 0; u < dst1->sy; u++) { - if (dTan >= 0.0) { - dShear = ((double)(u + 0.5)) * dTan; - } else { - dShear = ((double)(u - dst1->sy) + 0.5) * dTan; - } - - iShear = (int)floor(dShear); - gdImageSkewX(dst1, src, u, iShear, (dShear - iShear), clrBack, ignoretransparent); - } - - /* - The 1st shear may use the original clrBack as color index - Convert it once here - */ - if(!src->trueColor) { - clrBackR = gdImageRed(src, clrBack); - clrBackG = gdImageGreen(src, clrBack); - clrBackB = gdImageBlue(src, clrBack); - clrBackA = gdImageAlpha(src, clrBack); - clrBack = gdTrueColorAlpha(clrBackR, clrBackG, clrBackB, clrBackA); - } - /* 2nd shear */ - newx = dst1->sx; - - if (dSinE > 0.0) { - dOffset = (src->sx-1) * dSinE; - } else { - dOffset = -dSinE * (src->sx - newx); - } - - newy = (int) ((double) src->sx * fabs( dSinE ) + (double) src->sy * cos (dRadAngle))+1; - - if (src->trueColor) { - f = gdImageGetTrueColorPixel; - } else { - f = gdImageGetPixel; - } - dst2 = gdImageCreateTrueColor(newx, newy); - if (dst2 == NULL) { - gdImageDestroy(dst1); - return NULL; - } - -#ifdef HAVE_GD_BUNDLED - dst2->alphaBlendingFlag = gdEffectReplace; -#else - gdImageAlphaBlending(dst2, 0); -#endif - - if (ignoretransparent) { - dst2->transparent = dst1->transparent; - } - - for (u = 0; u < dst2->sx; u++, dOffset -= dSinE) { - iShear = (int)floor (dOffset); - gdImageSkewY(dst2, dst1, u, iShear, (dOffset - (double)iShear), clrBack, ignoretransparent); - } - - /* 3rd shear */ - gdImageDestroy(dst1); - - newx = (int) ((double)src->sy * fabs (dSinE) + (double)src->sx * cos (dRadAngle)) + 1; - newy = dst2->sy; - - if (src->trueColor) { - f = gdImageGetTrueColorPixel; - } else { - f = gdImageGetPixel; - } - dst3 = gdImageCreateTrueColor(newx, newy); - if (dst3 == NULL) { - gdImageDestroy(dst2); - return NULL; - } - -#ifdef HAVE_GD_BUNDLED - dst3->alphaBlendingFlag = gdEffectReplace; -#else - gdImageAlphaBlending(dst3, 0); -#endif - - if (ignoretransparent) { - dst3->transparent = dst2->transparent; - } - - if (dSinE >= 0.0) { - dOffset = (double)(src->sx - 1) * dSinE * -dTan; - } else { - dOffset = dTan * ((double)(src->sx - 1) * -dSinE + (double)(1 - newy)); - } - - for (u = 0; u < dst3->sy; u++, dOffset += dTan) { - int iShear = (int)floor(dOffset); - gdImageSkewX(dst3, dst2, u, iShear, (dOffset - iShear), clrBack, ignoretransparent); - } - - gdImageDestroy(dst2); - - return dst3; -} - -gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent) -{ - gdImagePtr pMidImg; - gdImagePtr rotatedImg; - - if (src == NULL) { - return NULL; - } - - if (!gdImageTrueColor(src) && (clrBack < 0 || clrBack>=gdImageColorsTotal(src))) { - return NULL; - } - - while (dAngle >= 360.0) { - dAngle -= 360.0; - } - - while (dAngle < 0) { - dAngle += 360.0; - } - - if (dAngle == 90.00) { - return gdImageRotate90(src, ignoretransparent); - } - if (dAngle == 180.00) { - return gdImageRotate180(src, ignoretransparent); - } - if(dAngle == 270.00) { - return gdImageRotate270 (src, ignoretransparent); - } - - if ((dAngle > 45.0) && (dAngle <= 135.0)) { - pMidImg = gdImageRotate90 (src, ignoretransparent); - dAngle -= 90.0; - } else if ((dAngle > 135.0) && (dAngle <= 225.0)) { - pMidImg = gdImageRotate180 (src, ignoretransparent); - dAngle -= 180.0; - } else if ((dAngle > 225.0) && (dAngle <= 315.0)) { - pMidImg = gdImageRotate270 (src, ignoretransparent); - dAngle -= 270.0; - } else { - return gdImageRotate45 (src, dAngle, clrBack, ignoretransparent); - } - - if (pMidImg == NULL) { - return NULL; - } - - rotatedImg = gdImageRotate45 (pMidImg, dAngle, clrBack, ignoretransparent); - gdImageDestroy(pMidImg); - - return rotatedImg; -} -/* End Rotate function */ - - |