diff --git a/NEWS b/NEWS index 48cb9167ff2..a94f4955dce 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,9 @@ PHP NEWS . Fixed bug #72308 (fastcgi_finish_request and logging environment variables). (Laruence) +- GD: + . Fixed bug #72337 (invalid dimensions can lead to crash) (Pierre) + - Intl: . Fixed bug #64524 (Add intl.use_exceptions to php.ini-*). (Anatol) @@ -1005,7 +1008,8 @@ PHP NEWS - GD: . Fixed bug #53156 (imagerectangle problem with point ordering). (cmb) - . Fixed bug #66387 (Stack overflow with imagefilltoborder). (cmb) + . Fixed bug #66387 (Stack overflow with imagefilltoborder). (CVE-2015-8874) + (cmb) . Fixed bug #70102 (imagecreatefromwebm() shifts colors). (cmb) . Fixed bug #66590 (imagewebp() doesn't pad to even length). (cmb) . Fixed bug #66882 (imagerotate by -90 degrees truncates image by 1px). (cmb) diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index b4278316726..0b0d933bfde 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1767,6 +1767,12 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color) return; } + if (!im->trueColor) { + if ((color > (im->colorsTotal - 1)) || (border > (im->colorsTotal - 1)) || (color < 0)) { + return; + } + } + restoreAlphaBlending = im->alphaBlendingFlag; im->alphaBlendingFlag = 0; diff --git a/ext/gd/tests/github_bug_215.phpt b/ext/gd/tests/github_bug_215.phpt new file mode 100644 index 00000000000..f44a5401e18 --- /dev/null +++ b/ext/gd/tests/github_bug_215.phpt @@ -0,0 +1,43 @@ +--TEST-- +Github #215 (imagefilltoborder stack overflow when invalid pallete index used) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +#1 passes +#2 passes +#3 passes +#4 passes +#5 passes