pajoye                                   Mon, 12 Oct 2009 10:01:37 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=289557

Log:
- check max colors while loading gd2 palette image (patch by Tomas Hoger)

Changed paths:
    U   php/php-src/branches/PHP_5_2/ext/gd/libgd/gd_gd.c
    A   php/php-src/branches/PHP_5_2/ext/gd/tests/crafted.gd2
    A   php/php-src/branches/PHP_5_2/ext/gd/tests/crafted_gd2.phpt
    U   php/php-src/branches/PHP_5_3/ext/gd/libgd/gd_gd.c
    A   php/php-src/branches/PHP_5_3/ext/gd/tests/crafted.gd2
    A   php/php-src/branches/PHP_5_3/ext/gd/tests/crafted_gd2.phpt
    U   php/php-src/branches/PHP_5_3_1/ext/gd/libgd/gd_gd.c
    A   php/php-src/branches/PHP_5_3_1/ext/gd/tests/crafted.gd2
    A   php/php-src/branches/PHP_5_3_1/ext/gd/tests/crafted_gd2.phpt
    U   php/php-src/trunk/ext/gd/libgd/gd_gd.c
    A   php/php-src/trunk/ext/gd/tests/crafted.gd2
    A   php/php-src/trunk/ext/gd/tests/crafted_gd2.phpt

Modified: php/php-src/branches/PHP_5_2/ext/gd/libgd/gd_gd.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/gd/libgd/gd_gd.c   2009-10-12 09:44:18 UTC 
(rev 289556)
+++ php/php-src/branches/PHP_5_2/ext/gd/libgd/gd_gd.c   2009-10-12 10:01:37 UTC 
(rev 289557)
@@ -39,6 +39,9 @@
                        if (!gdGetWord(&im->colorsTotal, in)) {
                                goto fail1;
                        }
+                       if (im->colorsTotal > gdMaxColors) {
+                               goto fail1;
+                       }
                }
                /* Int to accommodate truecolor single-color transparency */
                if (!gdGetInt(&im->transparent, in)) {

Added: php/php-src/branches/PHP_5_2/ext/gd/tests/crafted.gd2
===================================================================
(Binary files differ)


Property changes on: php/php-src/branches/PHP_5_2/ext/gd/tests/crafted.gd2
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: php/php-src/branches/PHP_5_2/ext/gd/tests/crafted_gd2.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/gd/tests/crafted_gd2.phpt                  
        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/gd/tests/crafted_gd2.phpt  2009-10-12 
10:01:37 UTC (rev 289557)
@@ -0,0 +1,16 @@
+--TEST--
+Test max colors for a gd image.
+--SKIPIF--
+<?php
+       if (!extension_loaded('gd')) {
+               die("skip gd extension not available\n");
+       }
+?>
+--FILE--
+<?php
+imagecreatefromgd(dirname(__FILE__) . '/crafted.gd2');
+?>
+--EXPECTF--
+
+Warning: imagecreatefromgd(): '%scrafted.gd2' is not a valid GD file in %s on 
line %d
+

Modified: php/php-src/branches/PHP_5_3/ext/gd/libgd/gd_gd.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/gd/libgd/gd_gd.c   2009-10-12 09:44:18 UTC 
(rev 289556)
+++ php/php-src/branches/PHP_5_3/ext/gd/libgd/gd_gd.c   2009-10-12 10:01:37 UTC 
(rev 289557)
@@ -39,6 +39,9 @@
                        if (!gdGetWord(&im->colorsTotal, in)) {
                                goto fail1;
                        }
+                       if (im->colorsTotal > gdMaxColors) {
+                               goto fail1;
+                       }
                }
                /* Int to accommodate truecolor single-color transparency */
                if (!gdGetInt(&im->transparent, in)) {

Added: php/php-src/branches/PHP_5_3/ext/gd/tests/crafted.gd2
===================================================================
(Binary files differ)


Property changes on: php/php-src/branches/PHP_5_3/ext/gd/tests/crafted.gd2
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: php/php-src/branches/PHP_5_3/ext/gd/tests/crafted_gd2.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/gd/tests/crafted_gd2.phpt                  
        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/gd/tests/crafted_gd2.phpt  2009-10-12 
10:01:37 UTC (rev 289557)
@@ -0,0 +1,16 @@
+--TEST--
+Test max colors for a gd image.
+--SKIPIF--
+<?php
+       if (!extension_loaded('gd')) {
+               die("skip gd extension not available\n");
+       }
+?>
+--FILE--
+<?php
+imagecreatefromgd(dirname(__FILE__) . '/crafted.gd2');
+?>
+--EXPECTF--
+
+Warning: imagecreatefromgd(): '%scrafted.gd2' is not a valid GD file in %s on 
line %d
+

Modified: php/php-src/branches/PHP_5_3_1/ext/gd/libgd/gd_gd.c
===================================================================
--- php/php-src/branches/PHP_5_3_1/ext/gd/libgd/gd_gd.c 2009-10-12 09:44:18 UTC 
(rev 289556)
+++ php/php-src/branches/PHP_5_3_1/ext/gd/libgd/gd_gd.c 2009-10-12 10:01:37 UTC 
(rev 289557)
@@ -39,6 +39,9 @@
                        if (!gdGetWord(&im->colorsTotal, in)) {
                                goto fail1;
                        }
+                       if (im->colorsTotal > gdMaxColors) {
+                               goto fail1;
+                       }
                }
                /* Int to accommodate truecolor single-color transparency */
                if (!gdGetInt(&im->transparent, in)) {

Added: php/php-src/branches/PHP_5_3_1/ext/gd/tests/crafted.gd2
===================================================================
(Binary files differ)


Property changes on: php/php-src/branches/PHP_5_3_1/ext/gd/tests/crafted.gd2
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: php/php-src/branches/PHP_5_3_1/ext/gd/tests/crafted_gd2.phpt
===================================================================
--- php/php-src/branches/PHP_5_3_1/ext/gd/tests/crafted_gd2.phpt                
                (rev 0)
+++ php/php-src/branches/PHP_5_3_1/ext/gd/tests/crafted_gd2.phpt        
2009-10-12 10:01:37 UTC (rev 289557)
@@ -0,0 +1,16 @@
+--TEST--
+Test max colors for a gd image.
+--SKIPIF--
+<?php
+       if (!extension_loaded('gd')) {
+               die("skip gd extension not available\n");
+       }
+?>
+--FILE--
+<?php
+imagecreatefromgd(dirname(__FILE__) . '/crafted.gd2');
+?>
+--EXPECTF--
+
+Warning: imagecreatefromgd(): '%scrafted.gd2' is not a valid GD file in %s on 
line %d
+

Modified: php/php-src/trunk/ext/gd/libgd/gd_gd.c
===================================================================
--- php/php-src/trunk/ext/gd/libgd/gd_gd.c      2009-10-12 09:44:18 UTC (rev 
289556)
+++ php/php-src/trunk/ext/gd/libgd/gd_gd.c      2009-10-12 10:01:37 UTC (rev 
289557)
@@ -39,6 +39,9 @@
                        if (!gdGetWord(&im->colorsTotal, in)) {
                                goto fail1;
                        }
+                       if (im->colorsTotal > gdMaxColors) {
+                               goto fail1;
+                       }
                }
                /* Int to accommodate truecolor single-color transparency */
                if (!gdGetInt(&im->transparent, in)) {

Added: php/php-src/trunk/ext/gd/tests/crafted.gd2
===================================================================
(Binary files differ)


Property changes on: php/php-src/trunk/ext/gd/tests/crafted.gd2
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: php/php-src/trunk/ext/gd/tests/crafted_gd2.phpt
===================================================================
--- php/php-src/trunk/ext/gd/tests/crafted_gd2.phpt                             
(rev 0)
+++ php/php-src/trunk/ext/gd/tests/crafted_gd2.phpt     2009-10-12 10:01:37 UTC 
(rev 289557)
@@ -0,0 +1,16 @@
+--TEST--
+Test max colors for a gd image.
+--SKIPIF--
+<?php
+       if (!extension_loaded('gd')) {
+               die("skip gd extension not available\n");
+       }
+?>
+--FILE--
+<?php
+imagecreatefromgd(dirname(__FILE__) . '/crafted.gd2');
+?>
+--EXPECTF--
+
+Warning: imagecreatefromgd(): '%scrafted.gd2' is not a valid GD file in %s on 
line %d
+

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to