com php-src: Fix #66387: Stack overflow with imagefilltoborder: ext/gd/libgd/gd.c ext/gd/tests/bug66387.phpt

From: Date: Mon, 20 Jul 2015 21:36:32 +0000
Subject: com php-src: Fix #66387: Stack overflow with imagefilltoborder: ext/gd/libgd/gd.c ext/gd/tests/bug66387.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-88067@lists.php.net to get a copy of this message
Commit: e7f2356665c2569191a946b6fc35b437f0ae1384 Author: Christoph M. Becker <cmb@php.net> Mon, 20 Jul 2015 23:24:55 +0200 Parents: 90de2aeaac3de8f0744853ba197457c2241a4bdf Branches: PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e7f2356665c2569191a946b6fc35b437f0ae1384 Log: Fix #66387: Stack overflow with imagefilltoborder The stack overflow is caused by the recursive algorithm in combination with a very large negative coordinate passed to gdImageFillToBorder(). As there is already a clipping for large positive coordinates to the width and height of the image, it seems to be consequent to clip to zero also. Bugs: https://bugs.php.net/66387 Changed paths: M ext/gd/libgd/gd.c A ext/gd/tests/bug66387.phpt Diff: diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index c75c985..529ba56 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1774,9 +1774,13 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color) if (x >= im->sx) { x = im->sx - 1; + } else if (x < 0) { + x = 0; } if (y >= im->sy) { y = im->sy - 1; + } else if (y < 0) { + y = 0; } for (i = x; i >= 0; i--) { diff --git a/ext/gd/tests/bug66387.phpt b/ext/gd/tests/bug66387.phpt new file mode 100644 index 0000000..79c49a5 --- /dev/null +++ b/ext/gd/tests/bug66387.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #66387 (Stack overflow with imagefilltoborder) +--SKIPIF-- +<?php +if (!extension_loaded('gd')) die('skip gd extension not available!'); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(20, 20); +$c = imagecolorallocate($im, 255, 0, 0); +imagefilltoborder($im, 0, -999355, $c, $c); +echo "ready\n"; +?> +--EXPECT-- +ready

« previous php.cvs (#88067) next »