com php-src: Merge branch 'PHP-5.5' into PHP-5.6: ext/gd/libgd/gd.c ext/gd/libgd/gd_interpolation.c ext/gd/tests/bug725 12.phpt
| From: | Ferenc Kovacs | Date: | Thu, 21 Jul 2016 00:08:53 +0000 |
| Subject: | com php-src: Merge branch 'PHP-5.5' into PHP-5.6: ext/gd/libgd/gd.c ext/gd/libgd/gd_interpolation.c ext/gd/tests/bug725 12.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93283@lists.php.net to get a copy of this message | ||
Commit: 210222928e52b95827a0b5e4a987303233597f89
Author: Pierre Joye <pierre.php@gmail.com> Tue, 19 Jul 2016 13:39:46 +0700
Committer: Ferenc Kovacs <tyra3l@gmail.com> Thu, 21 Jul 2016 02:08:53 +0200
Parents: a3564c4b5bfa94424fcd7df2400c23f1ca7fb4af
Branches: PHP-5.6.24
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=210222928e52b95827a0b5e4a987303233597f89
Log:
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
fix #72512, invalid read or write for palette image when invalid transparent index is used
Bugs:
https://bugs.php.net/72512
Changed paths:
M ext/gd/libgd/gd.c
M ext/gd/libgd/gd_interpolation.c
A ext/gd/tests/bug72512.phpt
Diff:
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c
index 3a7ca36..98e6080 100644
--- a/ext/gd/libgd/gd.c
+++ b/ext/gd/libgd/gd.c
@@ -599,15 +599,18 @@ void gdImageColorDeallocate (gdImagePtr im, int color)
void gdImageColorTransparent (gdImagePtr im, int color)
{
+ if (color < 0) {
+ return;
+ }
if (!im->trueColor) {
+ if((color >= im->colorsTotal)) {
+ return;
+ }
+ /* Make the old transparent color opaque again */
if (im->transparent != -1) {
im->alpha[im->transparent] = gdAlphaOpaque;
}
- if (color > -1 && color < im->colorsTotal && color < gdMaxColors) {
- im->alpha[color] = gdAlphaTransparent;
- } else {
- return;
- }
+ im->alpha[color] = gdAlphaTransparent;
}
im->transparent = color;
}
diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c
index 8162b7e..b9c4c28 100644
--- a/ext/gd/libgd/gd_interpolation.c
+++ b/ext/gd/libgd/gd_interpolation.c
@@ -1266,7 +1266,13 @@ static gdImagePtr gdImageScaleBilinearPalette(gdImagePtr im, const unsigned
int
if (new_img == NULL) {
return NULL;
}
- new_img->transparent = gdTrueColorAlpha(im->red[transparent], im->green[transparent],
im->blue[transparent], im->alpha[transparent]);
+
+ if (transparent < 0) {
+ /* uninitialized */
+ new_img->transparent = -1;
+ } else {
+ new_img->transparent = gdTrueColorAlpha(im->red[transparent], im->green[transparent],
im->blue[transparent], im->alpha[transparent]);
+ }
for (i=0; i < _height; i++) {
long j;
diff --git a/ext/gd/tests/bug72512.phpt b/ext/gd/tests/bug72512.phpt
new file mode 100644
index 0000000..2a2024d
--- /dev/null
+++ b/ext/gd/tests/bug72512.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #19366 (gdimagefill() function crashes (fixed in bundled libgd))
+--SKIPIF--
+<?php
+ if (!extension_loaded('gd')) die("skip gd extension not available\n");
+?>
+--FILE--
+<?php
+$img = imagecreatetruecolor(100, 100);
+imagecolortransparent($img, -1000000);
+imagetruecolortopalette($img, TRUE, 3);
+imagecolortransparent($img, 9);
+echo "OK";
+?>
+--EXPECT--
+OK
+