[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c
pajoye Fri Mar 10 18:07:27 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/gd gd.c Log: - #36686, do not be quiet with the extern GD http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd.c?r1=1.312.2.19r2=1.312.2.20diff_format=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.19 php-src/ext/gd/gd.c:1.312.2.20 --- php-src/ext/gd/gd.c:1.312.2.19 Sun Feb 5 15:53:58 2006 +++ php-src/ext/gd/gd.c Fri Mar 10 18:07:27 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.19 2006/02/05 15:53:58 pajoye Exp $ */ +/* $Id: gd.c,v 1.312.2.20 2006/03/10 18:07:27 pajoye Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -1094,6 +1094,7 @@ RETURN_TRUE; } +/* }}} */ #endif #if HAVE_GD_BUNDLED @@ -1635,7 +1636,11 @@ #ifdef HAVE_GD_JPG case PHP_GDIMG_TYPE_JPG: ignore_warning = INI_INT(gd.jpeg_ignore_warning); +#ifdef HAVE_GD_BUNDLED im = gdImageCreateFromJpeg(fp, ignore_warning); +#else + im = gdImageCreateFromJpeg(fp); +#endif break; #endif @@ -3918,7 +3923,11 @@ #ifdef HAVE_GD_JPG case PHP_GDIMG_TYPE_JPG: ignore_warning = INI_INT(gd.jpeg_ignore_warning); +#ifdef HAVE_GD_BUNDLED im_org = gdImageCreateFromJpeg(org, ignore_warning); +#else + im_org = gdImageCreateFromJpeg(org); +#endif if (im_org == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to open '%s' Not a valid JPEG file, fn_dest); RETURN_FALSE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c /ext/gd/libgd gd.h gd_jpeg.c
pajoye Sun Feb 5 15:53:58 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/gd gd.c /php-src/ext/gd/libgd gd.h gd_jpeg.c Log: - MFH: add a weak/tolerant mode to the jpeg loader http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd.c?r1=1.312.2.18r2=1.312.2.19diff_format=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.18 php-src/ext/gd/gd.c:1.312.2.19 --- php-src/ext/gd/gd.c:1.312.2.18 Fri Jan 27 20:46:02 2006 +++ php-src/ext/gd/gd.c Sun Feb 5 15:53:58 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.18 2006/01/27 20:46:02 mike Exp $ */ +/* $Id: gd.c,v 1.312.2.19 2006/02/05 15:53:58 pajoye Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -35,6 +35,7 @@ #endif #include php.h +#include php_ini.h #include ext/standard/head.h #include math.h #include SAPI.h @@ -357,6 +358,12 @@ ZEND_GET_MODULE(gd) #endif +/* {{{ PHP_INI_BEGIN */ +PHP_INI_BEGIN() + PHP_INI_ENTRY(gd.jpeg_ignore_warning, 0, PHP_INI_ALL, NULL) +PHP_INI_END() +/* }}} */ + /* {{{ php_free_gd_image */ static void php_free_gd_image(zend_rsrc_list_entry *rsrc TSRMLS_DC) @@ -405,6 +412,8 @@ le_ps_enc = zend_register_list_destructors_ex(php_free_ps_enc, NULL, gd PS encoding, module_number); #endif + REGISTER_INI_ENTRIES(); + REGISTER_LONG_CONSTANT(IMG_GIF, 1, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(IMG_JPG, 2, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(IMG_JPEG, 2, CONST_CS | CONST_PERSISTENT); @@ -1540,6 +1549,8 @@ php_stream *stream; FILE * fp = NULL; int argc=ZEND_NUM_ARGS(); + long ignore_warning; + if ((image_type == PHP_GDIMG_TYPE_GD2PART argc != 5) || (image_type != PHP_GDIMG_TYPE_GD2PART argc != 1) || @@ -1620,6 +1631,14 @@ im = gdImageCreateFromXpm(fn); break; #endif + +#ifdef HAVE_GD_JPG + case PHP_GDIMG_TYPE_JPG: + ignore_warning = INI_INT(gd.jpeg_ignore_warning); + im = gdImageCreateFromJpeg(fp, ignore_warning); + break; +#endif + default: im = (*func_p)(fp); break; @@ -3841,7 +3860,8 @@ int int_threshold; int x, y; float x_ratio, y_ratio; - +long ignore_warning; + if (argc != 5 || zend_get_parameters_ex(argc, f_org, f_dest, height, width, threshold) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); } @@ -3897,7 +3917,8 @@ #ifdef HAVE_GD_JPG case PHP_GDIMG_TYPE_JPG: - im_org = gdImageCreateFromJpeg(org); + ignore_warning = INI_INT(gd.jpeg_ignore_warning); + im_org = gdImageCreateFromJpeg(org, ignore_warning); if (im_org == NULL) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to open '%s' Not a valid JPEG file, fn_dest); RETURN_FALSE; http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/libgd/gd.h?r1=1.26.2.2r2=1.26.2.3diff_format=u Index: php-src/ext/gd/libgd/gd.h diff -u php-src/ext/gd/libgd/gd.h:1.26.2.2 php-src/ext/gd/libgd/gd.h:1.26.2.3 --- php-src/ext/gd/libgd/gd.h:1.26.2.2 Fri Jan 27 13:36:30 2006 +++ php-src/ext/gd/libgd/gd.h Sun Feb 5 15:53:58 2006 @@ -237,8 +237,8 @@ gdImagePtr gdImageCreateFromPngCtx(gdIOCtxPtr in); gdImagePtr gdImageCreateFromWBMP(FILE *inFile); gdImagePtr gdImageCreateFromWBMPCtx(gdIOCtx *infile); -gdImagePtr gdImageCreateFromJpeg(FILE *infile); -gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile); +gdImagePtr gdImageCreateFromJpeg(FILE *infile, int ignore_warning); +gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile, int ignore_warning); /* A custom data source. */ /* The source function must return -1 on error, otherwise the number http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/libgd/gd_jpeg.c?r1=1.18.4.1r2=1.18.4.2diff_format=u Index: php-src/ext/gd/libgd/gd_jpeg.c diff -u php-src/ext/gd/libgd/gd_jpeg.c:1.18.4.1 php-src/ext/gd/libgd/gd_jpeg.c:1.18.4.2 --- php-src/ext/gd/libgd/gd_jpeg.c:1.18.4.1 Thu Aug 18 12:54:43 2005 +++ php-src/ext/gd/libgd/gd_jpeg.c Sun Feb 5 15:53:58 2006 @@ -43,8 +43,44 @@ typedef struct _jmpbuf_wrapper { jmp_buf jmpbuf; + int ignore_warning; } jmpbuf_wrapper; +static long php_jpeg_emit_message(j_common_ptr jpeg_info, int level) +{ + char message[JMSG_LENGTH_MAX]; + jmpbuf_wrapper *jmpbufw; + int ignore_warning = 0; + +jmpbufw = (jmpbuf_wrapper *) jpeg_info-client_data; + + if (jmpbufw != 0) { + ignore_warning = jmpbufw-ignore_warning; +
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c gd_ctx.c /ext/gd/libgd gd.h gd_png.c
pajoye Fri Jan 27 13:36:30 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/gd gd.c gd_ctx.c /php-src/ext/gd/libgd gd.h gd_png.c Log: - MFH: add filter option to imagepng - add constants PS: If someone can check why #include png.h fails, it will be cleaner http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd.c?r1=1.312.2.16r2=1.312.2.17diff_format=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.16 php-src/ext/gd/gd.c:1.312.2.17 --- php-src/ext/gd/gd.c:1.312.2.16 Tue Jan 17 23:47:08 2006 +++ php-src/ext/gd/gd.c Fri Jan 27 13:36:29 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.16 2006/01/17 23:47:08 tony2001 Exp $ */ +/* $Id: gd.c,v 1.312.2.17 2006/01/27 13:36:29 pajoye Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -451,6 +451,22 @@ #else REGISTER_LONG_CONSTANT(GD_BUNDLED, 0, CONST_CS | CONST_PERSISTENT); #endif + +#ifdef HAVE_GD_PNG + +/* + * cannot include #include png.h + * /usr/include/pngconf.h:310:2: error: #error png.h already includes setjmp.h with some additional fixup. + * as error, use the values for now... + */ + REGISTER_LONG_CONSTANT(PNG_NO_FILTER, 0x00, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PNG_FILTER_NONE, 0x08, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PNG_FILTER_SUB,0x10, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PNG_FILTER_UP, 0x20, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PNG_FILTER_AVG,0x40, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PNG_FILTER_PAETH, 0x80, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT(PNG_ALL_FILTERS, 0x08 | 0x10 | 0x20 | 0x40 | 0x80, CONST_CS | CONST_PERSISTENT); +#endif return SUCCESS; } /* }}} */ http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd_ctx.c?r1=1.22.2.4r2=1.22.2.5diff_format=u Index: php-src/ext/gd/gd_ctx.c diff -u php-src/ext/gd/gd_ctx.c:1.22.2.4 php-src/ext/gd/gd_ctx.c:1.22.2.5 --- php-src/ext/gd/gd_ctx.c:1.22.2.4Sun Jan 1 12:50:06 2006 +++ php-src/ext/gd/gd_ctx.c Fri Jan 27 13:36:29 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: gd_ctx.c,v 1.22.2.4 2006/01/01 12:50:06 sniper Exp $ */ +/* $Id: gd_ctx.c,v 1.22.2.5 2006/01/27 13:36:29 pajoye Exp $ */ #include php_gd.h @@ -49,12 +49,13 @@ /* {{{ _php_image_output_ctx */ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, void (*func_p)()) { - zval **imgind, **file, **quality; + zval **imgind, **file, **quality, **basefilter; gdImagePtr im; char *fn = NULL; FILE *fp = NULL; int argc = ZEND_NUM_ARGS(); int q = -1, i; + int f = -1; gdIOCtx *ctx; /* The third (quality) parameter for Wbmp stands for the threshold when called from image2wbmp(). @@ -65,7 +66,8 @@ if (argc 2 image_type == PHP_GDIMG_TYPE_XBM) { WRONG_PARAM_COUNT; } - if (argc 1 || argc 3 || zend_get_parameters_ex(argc, imgind, file, quality) == FAILURE) + + if (argc 1 || argc 4 || zend_get_parameters_ex(argc, imgind, file, quality, basefilter) == FAILURE) { WRONG_PARAM_COUNT; } @@ -75,9 +77,13 @@ if (argc 1) { convert_to_string_ex(file); fn = Z_STRVAL_PP(file); - if (argc == 3) { + if (argc = 3) { convert_to_long_ex(quality); q = Z_LVAL_PP(quality);/* or colorindex for foreground of BW images (defaults to black) */ + if (argc == 4) { + convert_to_long_ex(basefilter); + f = Z_LVAL_PP(basefilter); + } } } @@ -115,9 +121,11 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid threshold value '%d'. It must be between 0 and 255, q); } case PHP_GDIMG_TYPE_JPG: - case PHP_GDIMG_TYPE_PNG: (*func_p)(im, ctx, q); break; + case PHP_GDIMG_TYPE_PNG: + (*func_p)(im, ctx, q, f); + break; case PHP_GDIMG_TYPE_XBM: case PHP_GDIMG_TYPE_WBM: if (argc 3) { http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/libgd/gd.h?r1=1.26.2.1r2=1.26.2.2diff_format=u Index: php-src/ext/gd/libgd/gd.h diff -u php-src/ext/gd/libgd/gd.h:1.26.2.1 php-src/ext/gd/libgd/gd.h:1.26.2.2 --- php-src/ext/gd/libgd/gd.h:1.26.2.1 Sun Oct 9 12:06:27 2005 +++ php-src/ext/gd/libgd/gd.h Fri Jan 27 13:36:30
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c
mikeFri Jan 27 20:46:03 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/gd gd.c Log: - include png.h prior php.h http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd.c?r1=1.312.2.17r2=1.312.2.18diff_format=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.17 php-src/ext/gd/gd.c:1.312.2.18 --- php-src/ext/gd/gd.c:1.312.2.17 Fri Jan 27 13:36:29 2006 +++ php-src/ext/gd/gd.c Fri Jan 27 20:46:02 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.17 2006/01/27 13:36:29 pajoye Exp $ */ +/* $Id: gd.c,v 1.312.2.18 2006/01/27 20:46:02 mike Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -29,6 +29,11 @@ #include config.h #endif +#ifdef HAVE_GD_PNG +/* needs to be first */ +#include png.h +#endif + #include php.h #include ext/standard/head.h #include math.h -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c
pajoye Tue Jan 17 15:23:29 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/gd gd.c Log: - Returns FALSE on error, it is how it must work http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd.c?r1=1.312.2.12r2=1.312.2.13diff_format=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.12 php-src/ext/gd/gd.c:1.312.2.13 --- php-src/ext/gd/gd.c:1.312.2.12 Sun Jan 1 12:50:06 2006 +++ php-src/ext/gd/gd.c Tue Jan 17 15:23:29 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.12 2006/01/01 12:50:06 sniper Exp $ */ +/* $Id: gd.c,v 1.312.2.13 2006/01/17 15:23:29 pajoye Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -1095,6 +1095,7 @@ zval *IM; long red, green, blue, alpha; gdImagePtr im; + int ct = (-1); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z, IM, red, green, blue, alpha) == FAILURE) { RETURN_FALSE; @@ -1103,6 +1104,12 @@ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, Image, le_gd); RETURN_LONG(gdImageColorAllocateAlpha(im, red, green, blue, alpha)); + ct = gdImageColorAllocateAlpha(im, red, green, blue, alpha); + if (ct 0) { + RETURN_FALSE; + } + + RETURN_LONG((long)ct); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c
FYI, this actually breaks BC. A negative number evaluates to true. I don't think this change should be an issue but there might have been people who did a 0 check before. Anyone got a problem with the change? At 07:44 AM 1/17/2006, Pierre-Alain Joye wrote: pajoye Tue Jan 17 15:44:12 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/gd gd.c Log: - return false on error http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd.c?r1=1.312.2.13r2=1.312.2.14diff_format=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.13 php-src/ext/gd/gd.c:1.312.2.14 --- php-src/ext/gd/gd.c:1.312.2.13 Tue Jan 17 15:23:29 2006 +++ php-src/ext/gd/gd.c Tue Jan 17 15:44:12 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.13 2006/01/17 15:23:29 pajoye Exp $ */ +/* $Id: gd.c,v 1.312.2.14 2006/01/17 15:44:12 pajoye Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -1967,6 +1967,7 @@ { zval **IM, **red, **green, **blue; gdImagePtr im; + int ct = (-1); if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, IM, red, green, blue) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); @@ -1977,8 +1978,11 @@ convert_to_long_ex(red); convert_to_long_ex(green); convert_to_long_ex(blue); - - RETURN_LONG(gdImageColorAllocate(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue))); + ct = gdImageColorAllocate(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue)); + if (ct 0) { + RETURN_FALSE; + } + RETURN_LONG(ct); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c
@@ -1095,6 +1095,7 @@ zval *IM; long red, green, blue, alpha; gdImagePtr im; + int ct = (-1); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z, IM, red, green, blue, alpha) == FAILURE) { RETURN_FALSE; @@ -1103,6 +1104,12 @@ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, Image, le_gd); you forgot to remove the line below: RETURN_LONG(gdImageColorAllocateAlpha(im, red, green, blue, alpha)); + ct = gdImageColorAllocateAlpha(im, red, green, blue, alpha); + if (ct 0) { + RETURN_FALSE; + } + + RETURN_LONG((long)ct); } /* }}} */ Nuno -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c
tony2001Tue Jan 17 23:47:09 2006 UTC Modified files: (Branch: PHP_5_1) /php-src/ext/gd gd.c Log: MFH: improve open_basedir checks in GD http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd.c?r1=1.312.2.15r2=1.312.2.16diff_format=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.15 php-src/ext/gd/gd.c:1.312.2.16 --- php-src/ext/gd/gd.c:1.312.2.15 Tue Jan 17 19:04:06 2006 +++ php-src/ext/gd/gd.c Tue Jan 17 23:47:08 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.15 2006/01/17 19:04:06 pajoye Exp $ */ +/* $Id: gd.c,v 1.312.2.16 2006/01/17 23:47:08 tony2001 Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -3201,6 +3201,8 @@ fontname = (unsigned char *) fontname; #endif + PHP_GD_CHECK_OPEN_BASEDIR(fontname, Invalid font filename); + #ifdef USE_GD_IMGSTRTTF # if HAVE_GD_STRINGFTEX if (extended) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c
iliaa Thu Dec 29 21:59:39 2005 EDT Modified files: (Branch: PHP_5_1) /php-src/ext/gd gd.c Log: Not a fatal error. http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd.c?r1=1.312.2.10r2=1.312.2.11diff_format=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.10 php-src/ext/gd/gd.c:1.312.2.11 --- php-src/ext/gd/gd.c:1.312.2.10 Sun Dec 25 20:33:05 2005 +++ php-src/ext/gd/gd.c Thu Dec 29 21:59:39 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.10 2005/12/25 20:33:05 pajoye Exp $ */ +/* $Id: gd.c,v 1.312.2.11 2005/12/29 21:59:39 iliaa Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -3402,7 +3402,7 @@ T1_DeleteAllSizes(*f_ind); if (Z_DVAL_PP(ext) = 0) { - php_error_docref(NULL TSRMLS_CC, E_ERROR, Second parameter %f out of range (must be 0), Z_DVAL_PP(ext)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Second parameter %f out of range (must be 0), Z_DVAL_PP(ext)); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c /ext/gd/libgd gd_topal.c /ext/gd/tests colormatch.phpt
pajoye Sun Dec 25 19:39:54 2005 EDT Added files: (Branch: PHP_5_1) /php-src/ext/gd/tests colormatch.phpt Modified files: /php-src/ext/gd gd.c /php-src/ext/gd/libgd gd_topal.c Log: - MFH: fix segfault/leak in imagecolormatch - MFH: test for imagecolormatch http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd.c?r1=1.312.2.8r2=1.312.2.9diff_format=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.8 php-src/ext/gd/gd.c:1.312.2.9 --- php-src/ext/gd/gd.c:1.312.2.8 Sat Dec 17 17:46:59 2005 +++ php-src/ext/gd/gd.c Sun Dec 25 19:39:53 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.8 2005/12/17 17:46:59 pajoye Exp $ */ +/* $Id: gd.c,v 1.312.2.9 2005/12/25 19:39:53 pajoye Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -930,6 +930,10 @@ php_error_docref(NULL TSRMLS_CC, E_ERROR, Image1 and Image2 must be the same size ); RETURN_FALSE; break; + case -4: + php_error_docref(NULL TSRMLS_CC, E_ERROR, Image2 must have at least one color ); + RETURN_FALSE; + break; } RETURN_TRUE; http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/libgd/gd_topal.c?r1=1.17r2=1.17.2.1diff_format=u Index: php-src/ext/gd/libgd/gd_topal.c diff -u php-src/ext/gd/libgd/gd_topal.c:1.17 php-src/ext/gd/libgd/gd_topal.c:1.17.2.1 --- php-src/ext/gd/libgd/gd_topal.c:1.17Wed Aug 11 23:25:50 2004 +++ php-src/ext/gd/libgd/gd_topal.c Sun Dec 25 19:39:53 2005 @@ -2086,6 +2086,9 @@ if( (im1-sx != im2-sx) || (im1-sy != im2-sy) ) { return -3; /* the images are meant to be the same dimensions */ } + if (im2-colorsTotal1) { + return -4; /* At least 1 color must be allocated */ + } buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * im2-colorsTotal, 0); memset( buf, 0, sizeof(unsigned long) * 5 * im2-colorsTotal ); http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/tests/colormatch.phpt?view=markuprev=1.1 Index: php-src/ext/gd/tests/colormatch.phpt +++ php-src/ext/gd/tests/colormatch.phpt --TEST-- imagecolormatch --SKIPIF-- ?php if (!function_exists('imagecolormatch')) die(skip gd extension not available\n); ? --FILE-- ?php $im = imagecreatetruecolor(5,5); $im2 = imagecreate(5,5); imagecolormatch($im, $im2); echo ok\n; imagedestroy($im); ? --EXPECTF-- Fatal error: imagecolormatch(): Image2 must have at least one color in %s on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c
pajoye Sun Dec 25 20:33:05 2005 EDT Modified files: (Branch: PHP_5_1) /php-src/ext/gd gd.c Log: - MFH: raise warnings instead of errors in colormatch http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd.c?r1=1.312.2.9r2=1.312.2.10diff_format=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.9 php-src/ext/gd/gd.c:1.312.2.10 --- php-src/ext/gd/gd.c:1.312.2.9 Sun Dec 25 19:39:53 2005 +++ php-src/ext/gd/gd.c Sun Dec 25 20:33:05 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.9 2005/12/25 19:39:53 pajoye Exp $ */ +/* $Id: gd.c,v 1.312.2.10 2005/12/25 20:33:05 pajoye Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -919,19 +919,19 @@ result = gdImageColorMatch(im1, im2); switch (result) { case -1: - php_error_docref(NULL TSRMLS_CC, E_ERROR, Image1 must be TrueColor ); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Image1 must be TrueColor ); RETURN_FALSE; break; case -2: - php_error_docref(NULL TSRMLS_CC, E_ERROR, Image2 must be Palette ); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Image2 must be Palette ); RETURN_FALSE; break; case -3: - php_error_docref(NULL TSRMLS_CC, E_ERROR, Image1 and Image2 must be the same size ); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Image1 and Image2 must be the same size ); RETURN_FALSE; break; case -4: - php_error_docref(NULL TSRMLS_CC, E_ERROR, Image2 must have at least one color ); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Image2 must have at least one color ); RETURN_FALSE; break; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c /ext/gd/tests copypalette.phpt createfromstring.phpt src.png
pajoye Sat Dec 17 17:46:59 2005 EDT Added files: (Branch: PHP_5_1) /php-src/ext/gd/tests copypalette.phpt createfromstring.phpt src.png Modified files: /php-src/ext/gd gd.c Log: - MFH: - fix leaks and wrong error when invalid/empty string are given to imagecreatefromstring - add test for imagecreatefromstring - add test for palettecopy http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd.c?r1=1.312.2.7r2=1.312.2.8diff_format=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.7 php-src/ext/gd/gd.c:1.312.2.8 --- php-src/ext/gd/gd.c:1.312.2.7 Fri Dec 9 18:07:56 2005 +++ php-src/ext/gd/gd.c Sat Dec 17 17:46:59 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.7 2005/12/09 18:07:56 pajoye Exp $ */ +/* $Id: gd.c,v 1.312.2.8 2005/12/17 17:46:59 pajoye Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -1429,6 +1429,11 @@ } convert_to_string_ex(data); + if (Z_STRLEN_PP(data) 8) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Empty string or invalid image); + RETURN_FALSE; + } + memcpy(sig, Z_STRVAL_PP(data), 8); imtype = _php_image_type(sig); @@ -1480,7 +1485,7 @@ break; default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, Data is not in a recognized format.); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Data is not in a recognized format); RETURN_FALSE; } http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/tests/copypalette.phpt?view=markuprev=1.1 Index: php-src/ext/gd/tests/copypalette.phpt +++ php-src/ext/gd/tests/copypalette.phpt --TEST-- imagepalettecopy --SKIPIF-- ?php if (!function_exists('imagecolorat')) die(skip gd extension not available\n); ? --FILE-- ?php $im = imagecreate(1,1); for ($i=0; $i256; $i++) { imagecolorallocate($im, $i, $i, $i); } $im2 = imagecreate(1,1); imagepalettecopy($im2, $im); for ($i=0; $i256; $i++) { $c = imagecolorsforindex($im2, $i); if ($c['red']!=$i || $c['green']!=$i || $c['blue']!=$i) { $failed = true; break; } } echo copy palette 255 colors: ; echo $failed ? 'failed' : 'ok'; echo \n; $im = imagecreate(1,1); $im2 = imagecreate(1,1); imagecolorallocatealpha($im, 0,0,0,100); imagepalettecopy($im2, $im); $c = imagecolorsforindex($im2, 0); if ($c['red']!=0 || $c['green']!=0 || $c['blue']!=0 || $c['alpha']!=100) { $failed = true; } echo 'copy palette 1 color and alpha: '; echo $failed ? 'failed' : 'ok'; echo \n; ? --EXPECT-- copy palette 255 colors: ok copy palette 1 color and alpha: ok http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/tests/createfromstring.phpt?view=markuprev=1.1 Index: php-src/ext/gd/tests/createfromstring.phpt +++ php-src/ext/gd/tests/createfromstring.phpt --TEST-- imagecreatefromstring --SKIPIF-- ?php if (!function_exists('imagecreatefromstring')) die(skip gd extension not available\n); ? --FILE-- ?php $dir = dirname(__FILE__); $im = imagecreatetruecolor(5,5); imagefill($im, 0,0, 0xff); imagesetpixel($im, 3,3, 0x0); imagepng($im, $dir . '/tc.png'); $im_string = file_get_contents(dirname(__FILE__) . '/tc.png'); $im = imagecreatefromstring($im_string); echo 'createfromstring truecolor png: '; if (imagecolorat($im, 3,3) != 0x0) { echo 'failed'; } else { echo 'ok'; } echo \n; unlink($dir . '/tc.png'); $im = imagecreate(5,5); $c1 = imagecolorallocate($im, 255,255,255); $c2 = imagecolorallocate($im, 255,0,0); imagefill($im, 0,0, $c1); imagesetpixel($im, 3,3, $c2); imagepng($im, $dir . '/p.png'); $im_string = file_get_contents(dirname(__FILE__) . '/p.png'); $im = imagecreatefromstring($im_string); echo'createfromstring palette png: '; $c = imagecolorsforindex($im, imagecolorat($im, 3,3)); $failed = false; if ($c['red'] != 255 || $c['green'] != 0 || $c['blue'] != 0) { echo 'failed'; } else { echo 'ok'; } echo \n; unlink($dir . '/p.png'); //empty string $im = imagecreatefromstring(''); //random string 8 $im = imagecreatefromstring(' asdf jklp'); ? --EXPECTF-- createfromstring truecolor png: ok createfromstring palette png: ok Warning: imagecreatefromstring(): Empty string or invalid image in %screatefromstring.php on line %d Warning: imagecreatefromstring(): Data is not in a recognized format in %screatefromstring.php on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c
sniper Mon Dec 5 20:21:29 2005 EDT Modified files: (Branch: PHP_5_1) /php-src/ext/gd gd.c Log: MFH: nuke php3 legacy http://cvs.php.net/diff.php/php-src/ext/gd/gd.c?r1=1.312.2.4r2=1.312.2.5ty=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.4 php-src/ext/gd/gd.c:1.312.2.5 --- php-src/ext/gd/gd.c:1.312.2.4 Tue Nov 1 12:05:09 2005 +++ php-src/ext/gd/gd.c Mon Dec 5 20:21:28 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.4 2005/11/01 17:05:09 sniper Exp $ */ +/* $Id: gd.c,v 1.312.2.5 2005/12/06 01:21:28 sniper Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -2597,7 +2597,7 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled) { zval **IM, **POINTS, **NPOINTS, **COL; - pval **var = NULL; + zval **var = NULL; gdImagePtr im; gdPointPtr points; int npoints, col, nelem, i; @@ -4190,7 +4190,7 @@ PHP_FUNCTION(imageconvolution) { zval *SIM, *hash_matrix; - pval **var = NULL, **var2 = NULL; + zval **var = NULL, **var2 = NULL; gdImagePtr im_src = NULL; double div, offset; int nelem, i, j, res; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c gd_ctx.c php_gd.h
sniper Tue Nov 1 12:05:10 2005 EDT Modified files: (Branch: PHP_5_1) /php-src/ext/gd gd.c gd_ctx.c php_gd.h Log: MFH: - Added missing safe-mode checks # Added by replacing the existing open_basedir checks with a macro # Also, the filename passed might be null, etc. so it's not very good # idea to pass to php_error_docref() (catch by Ilia) http://cvs.php.net/diff.php/php-src/ext/gd/gd.c?r1=1.312.2.3r2=1.312.2.4ty=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.3 php-src/ext/gd/gd.c:1.312.2.4 --- php-src/ext/gd/gd.c:1.312.2.3 Wed Oct 26 17:38:20 2005 +++ php-src/ext/gd/gd.c Tue Nov 1 12:05:09 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.3 2005/10/26 21:38:20 tony2001 Exp $ */ +/* $Id: gd.c,v 1.312.2.4 2005/11/01 17:05:09 sniper Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -706,7 +706,7 @@ convert_to_string_ex(file); - stream = php_stream_open_wrapper(Z_STRVAL_PP(file), rb, IGNORE_PATH | IGNORE_URL_WIN | REPORT_ERRORS, NULL); + stream = php_stream_open_wrapper(Z_STRVAL_PP(file), rb, ENFORCE_SAFE_MODE | IGNORE_PATH | IGNORE_URL_WIN | REPORT_ERRORS, NULL); if (stream == NULL) { RETURN_FALSE; } @@ -1519,7 +1519,7 @@ fn = Z_STRVAL_PP(file); - stream = php_stream_open_wrapper(fn, rb, REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL); + stream = php_stream_open_wrapper(fn, rb, ENFORCE_SAFE_MODE|REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL); if (stream == NULL) { RETURN_FALSE; } @@ -1727,10 +1727,7 @@ } if ((argc == 2) || (argc 2 Z_STRLEN_PP(file))) { - if (!fn || php_check_open_basedir(fn TSRMLS_CC) || (PG(safe_mode) !php_checkuid(fn, rb+, CHECKUID_CHECK_FILE_AND_DIR))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid filename '%s', fn); - RETURN_FALSE; - } + PHP_GD_CHECK_OPEN_BASEDIR(fn, Invalid filename); fp = VCWD_FOPEN(fn, wb); if (!fp) { @@ -3826,16 +3823,10 @@ } /* Check origin file */ - if (!fn_org || php_check_open_basedir(fn_org TSRMLS_CC)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid origin filename '%s', fn_org); - RETURN_FALSE; - } + PHP_GD_CHECK_OPEN_BASEDIR(fn_org, Invalid origin filename); /* Check destination file */ - if (!fn_dest || php_check_open_basedir(fn_dest TSRMLS_CC)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid destination filename '%s', fn_dest); - RETURN_FALSE; - } + PHP_GD_CHECK_OPEN_BASEDIR(fn_dest, Invalid destination filename); /* Open origin file */ org = VCWD_FOPEN(fn_org, rb); http://cvs.php.net/diff.php/php-src/ext/gd/gd_ctx.c?r1=1.22.2.1r2=1.22.2.2ty=u Index: php-src/ext/gd/gd_ctx.c diff -u php-src/ext/gd/gd_ctx.c:1.22.2.1 php-src/ext/gd/gd_ctx.c:1.22.2.2 --- php-src/ext/gd/gd_ctx.c:1.22.2.1Thu Oct 6 16:47:40 2005 +++ php-src/ext/gd/gd_ctx.c Tue Nov 1 12:05:09 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: gd_ctx.c,v 1.22.2.1 2005/10/06 20:47:40 iliaa Exp $ */ +/* $Id: gd_ctx.c,v 1.22.2.2 2005/11/01 17:05:09 sniper Exp $ */ #include php_gd.h @@ -82,10 +82,8 @@ } if ((argc == 2) || (argc 2 Z_STRLEN_PP(file))) { - if (!fn || php_check_open_basedir(fn TSRMLS_CC) || (PG(safe_mode) !php_checkuid(fn, rb+, CHECKUID_CHECK_FILE_AND_DIR))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid filename '%s', fn); - RETURN_FALSE; - } + + PHP_GD_CHECK_OPEN_BASEDIR(fn, Invalid filename); fp = VCWD_FOPEN(fn, wb); if (!fp) { http://cvs.php.net/diff.php/php-src/ext/gd/php_gd.h?r1=1.59r2=1.59.2.1ty=u Index: php-src/ext/gd/php_gd.h diff -u php-src/ext/gd/php_gd.h:1.59 php-src/ext/gd/php_gd.h:1.59.2.1 --- php-src/ext/gd/php_gd.h:1.59Wed Aug 3 10:07:13 2005 +++ php-src/ext/gd/php_gd.h Tue Nov 1 12:05:09 2005 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: php_gd.h,v 1.59 2005/08/03 14:07:13 sniper Exp $ */ +/* $Id: php_gd.h,v 1.59.2.1 2005/11/01 17:05:09 sniper Exp $ */ #ifndef PHP_GD_H #define PHP_GD_H @@ -30,6 +30,15 @@ #if HAVE_LIBGD +/* open_basedir and safe_mode checks */ +#define PHP_GD_CHECK_OPEN_BASEDIR(filename, errormsg) \ + if (!filename || php_check_open_basedir(filename TSRMLS_CC) || \ + (PG(safe_mode) !php_checkuid(filename, rb+,
[PHP-CVS] cvs: php-src(PHP_5_1) /ext/gd gd.c
pajoye Tue Oct 25 19:00:22 2005 EDT Modified files: (Branch: PHP_5_1) /php-src/ext/gd gd.c Log: - fix #34980, divisor and offset never passed correctly (s/float/double/) http://cvs.php.net/diff.php/php-src/ext/gd/gd.c?r1=1.312.2.1r2=1.312.2.2ty=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.312.2.1 php-src/ext/gd/gd.c:1.312.2.2 --- php-src/ext/gd/gd.c:1.312.2.1 Thu Oct 6 16:47:40 2005 +++ php-src/ext/gd/gd.c Tue Oct 25 19:00:19 2005 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.312.2.1 2005/10/06 20:47:40 iliaa Exp $ */ +/* $Id: gd.c,v 1.312.2.2 2005/10/25 23:00:19 pajoye Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -4197,7 +4197,7 @@ zval *SIM, *hash_matrix; pval **var = NULL, **var2 = NULL; gdImagePtr im_src = NULL; - float div, offset; + double div, offset; int nelem, i, j, res; float matrix[3][3] = {{0,0,0}, {0,0,0}, {0,0,0}}; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php