[PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c
tony2001Wed Jul 23 08:56:38 2008 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/bz2bz2.c Log: MFH: add PHP_STREAM_FLAG_FCLOSE, bz2 streams can be closed with fclose() http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.13r2=1.14.2.3.2.14diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.13 php-src/ext/bz2/bz2.c:1.14.2.3.2.14 --- php-src/ext/bz2/bz2.c:1.14.2.3.2.13 Mon Dec 31 07:20:04 2007 +++ php-src/ext/bz2/bz2.c Wed Jul 23 08:56:37 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.14.2.3.2.13 2007/12/31 07:20:04 sebastian Exp $ */ +/* $Id: bz2.c,v 1.14.2.3.2.14 2008/07/23 08:56:37 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -247,7 +247,9 @@ if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **) fd, REPORT_ERRORS)) { bz_file = BZ2_bzdopen(fd, mode); } + stream-flags |= PHP_STREAM_FLAG_FCLOSE; } + /* remove the file created by php_stream_open_wrapper(), it is not needed since BZ2 functions * failed. */ @@ -259,6 +261,7 @@ if (bz_file) { retstream = _php_stream_bz2open_from_BZFILE(bz_file, mode, stream STREAMS_REL_CC TSRMLS_CC); if (retstream) { + retstream-flags |= PHP_STREAM_FLAG_FCLOSE; return retstream; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c /ext/standard dir.c file.c fsock.c proc_open.c streamsfuncs.c /ext/zip zip_stream.c /main php_streams.h /sapi/cli php_cli.c
tony2001Wed Jul 23 11:25:51 2008 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/bz2bz2.c /php-src/ext/standard dir.c file.c fsock.c proc_open.c streamsfuncs.c /php-src/ext/zipzip_stream.c /php-src/main php_streams.h /php-src/sapi/cli php_cli.c Log: MFH: invert the logics - FLAG_FCLOSE - FLAG_NO_FCLOSE http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.14r2=1.14.2.3.2.15diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.14 php-src/ext/bz2/bz2.c:1.14.2.3.2.15 --- php-src/ext/bz2/bz2.c:1.14.2.3.2.14 Wed Jul 23 08:56:37 2008 +++ php-src/ext/bz2/bz2.c Wed Jul 23 11:25:50 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.14.2.3.2.14 2008/07/23 08:56:37 tony2001 Exp $ */ +/* $Id: bz2.c,v 1.14.2.3.2.15 2008/07/23 11:25:50 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -247,7 +247,6 @@ if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **) fd, REPORT_ERRORS)) { bz_file = BZ2_bzdopen(fd, mode); } - stream-flags |= PHP_STREAM_FLAG_FCLOSE; } /* remove the file created by php_stream_open_wrapper(), it is not needed since BZ2 functions @@ -261,7 +260,6 @@ if (bz_file) { retstream = _php_stream_bz2open_from_BZFILE(bz_file, mode, stream STREAMS_REL_CC TSRMLS_CC); if (retstream) { - retstream-flags |= PHP_STREAM_FLAG_FCLOSE; return retstream; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dir.c?r1=1.147.2.3.2.17r2=1.147.2.3.2.18diff_format=u Index: php-src/ext/standard/dir.c diff -u php-src/ext/standard/dir.c:1.147.2.3.2.17 php-src/ext/standard/dir.c:1.147.2.3.2.18 --- php-src/ext/standard/dir.c:1.147.2.3.2.17 Wed Jun 11 09:02:09 2008 +++ php-src/ext/standard/dir.c Wed Jul 23 11:25:50 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dir.c,v 1.147.2.3.2.17 2008/06/11 09:02:09 dmitry Exp $ */ +/* $Id: dir.c,v 1.147.2.3.2.18 2008/07/23 11:25:50 tony2001 Exp $ */ /* {{{ includes/startup/misc */ @@ -220,6 +220,8 @@ if (dirp == NULL) { RETURN_FALSE; } + + dirp-flags |= PHP_STREAM_FLAG_NO_FCLOSE; php_set_default_dir(dirp-rsrc_id TSRMLS_CC); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.409.2.6.2.33r2=1.409.2.6.2.34diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.409.2.6.2.33 php-src/ext/standard/file.c:1.409.2.6.2.34 --- php-src/ext/standard/file.c:1.409.2.6.2.33 Tue Jul 22 14:11:25 2008 +++ php-src/ext/standard/file.c Wed Jul 23 11:25:50 2008 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.409.2.6.2.33 2008/07/22 14:11:25 felipe Exp $ */ +/* $Id: file.c,v 1.409.2.6.2.34 2008/07/23 11:25:50 tony2001 Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -861,8 +861,6 @@ stream = php_stream_fopen_tmpfile(); if (stream) { - stream-flags |= PHP_STREAM_FLAG_FCLOSE; - php_stream_to_zval(stream, return_value); } else { RETURN_FALSE; @@ -894,8 +892,6 @@ RETURN_FALSE; } - stream-flags |= PHP_STREAM_FLAG_FCLOSE; - php_stream_to_zval(stream, return_value); if (zcontext) { @@ -917,7 +913,7 @@ PHP_STREAM_TO_ZVAL(stream, arg1); - if (!(stream-flags PHP_STREAM_FLAG_FCLOSE)) { + if ((stream-flags PHP_STREAM_FLAG_NO_FCLOSE) != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, %d is not a valid stream resource, stream-rsrc_id); RETURN_FALSE; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/fsock.c?r1=1.121.2.1.2.3r2=1.121.2.1.2.4diff_format=u Index: php-src/ext/standard/fsock.c diff -u php-src/ext/standard/fsock.c:1.121.2.1.2.3 php-src/ext/standard/fsock.c:1.121.2.1.2.4 --- php-src/ext/standard/fsock.c:1.121.2.1.2.3 Tue Jul 22 14:11:25 2008 +++ php-src/ext/standard/fsock.cWed Jul 23 11:25:50 2008 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: fsock.c,v 1.121.2.1.2.3 2008/07/22 14:11:25 felipe Exp $ */ +/* $Id: fsock.c,v 1.121.2.1.2.4 2008/07/23 11:25:50 tony2001 Exp $ */ #include php.h #include php_globals.h @@ -79,8 +79,6 @@ stream = php_stream_xport_create(hostname, hostname_len, ENFORCE_SAFE_MODE | REPORT_ERRORS, STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, hashkey, tv, NULL, errstr, err); - stream-flags |=
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c
stasTue Mar 6 02:10:25 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/bz2bz2.c Log: use safe_realloc http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.10r2=1.14.2.3.2.11diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.10 php-src/ext/bz2/bz2.c:1.14.2.3.2.11 --- php-src/ext/bz2/bz2.c:1.14.2.3.2.10 Mon Jan 1 09:35:48 2007 +++ php-src/ext/bz2/bz2.c Tue Mar 6 02:10:25 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.14.2.3.2.10 2007/01/01 09:35:48 sebastian Exp $ */ +/* $Id: bz2.c,v 1.14.2.3.2.11 2007/03/06 02:10:25 stas Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -562,13 +562,13 @@ /* compression is better then 2:1, need to allocate more memory */ bzs.avail_out = source_len; size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32; - dest = erealloc(dest, size + bzs.avail_out + 1); + dest = safe_erealloc(dest, 1, bzs.avail_out+1, size ); bzs.next_out = dest + size; } if (error == BZ_STREAM_END || error == BZ_OK) { size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32; - dest = erealloc(dest, size + 1); + dest = safe_erealloc(dest, 1, size, 1); dest[size] = '\0'; RETVAL_STRINGL(dest, size, 0); } else { /* real error */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c
tony2001Mon Dec 25 20:03:43 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/bz2bz2.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.8r2=1.14.2.3.2.9diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.8 php-src/ext/bz2/bz2.c:1.14.2.3.2.9 --- php-src/ext/bz2/bz2.c:1.14.2.3.2.8 Thu Aug 17 20:46:51 2006 +++ php-src/ext/bz2/bz2.c Mon Dec 25 20:03:43 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.14.2.3.2.8 2006/08/17 20:46:51 tony2001 Exp $ */ +/* $Id: bz2.c,v 1.14.2.3.2.9 2006/12/25 20:03:43 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -330,7 +330,7 @@ php_stream_from_zval(stream, bz); - if (len 0) { + if ((len + 1) 1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, length may not be negative); RETURN_FALSE; } -- 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_2) /ext/bz2 bz2.c php_bz2.h /ext/ctype ctype.c php_ctype.h /ext/json json.c php_json.h /ext/pspell php_pspell.h pspell.c /ext/tidy php_tidy.h tidy.c /ext/zlib php_
Hello, Sorry for the late answer, but I was on vacations and without internet access. Thanks for the support Marcus. Marking functions as static also reduces code size. When building PHP with -fPIC the decrease in size is really noticeable. constifying allows the OS to share memory pages between proccesses, reducing the overall memory usage. btw, I have a couple of patches (that play with the compilers) waiting for someone from the Zend Engine team to review. Can someone please take a look at them? For example, http://mega.ist.utl.pt/~ncpl/php_gcc4_visibility.txt reduces the dso size when used with gcc 4. I also like this one: http://mega.ist.utl.pt/~ncpl/zend_arginfo_const.txt plus the huge one: http://mega.ist.utl.pt/~ncpl/Zend_2nd_constify_patch.txt Nuno P.S.: I would like to keep messing with compiler options, as compilers are one of my passions :) - Original Message - Hello Andi, one thing it helps in is that having it as non static makes some compilers use an additional jump. Actually for shared dlls those functions might end up in the jump table that is going to be initialized during loading process. So infact there might be some advantage in doing it this way. Also constifying is one of our overall goals since long. And here we finally have someone willing to do the job, why not letting him do it? best regards marcus Saturday, August 26, 2006, 1:19:01 PM, you wrote: I don't think it helps. It won't inline these functions in most cases anyway, and having or not having a symbol shouldn't make a difference. I'd prefer to stick to our standards and keep all extensions the same. Who knows if/when we'll want to play around with the symbols also. It could come in handly with dlls. Andi -Original Message- From: Ilia Alshanetsky [mailto:[EMAIL PROTECTED] On Behalf Of Ilia Alshanetsky Sent: Saturday, August 26, 2006 9:59 AM To: Andi Gutmans Cc: 'Nuno Lopes'; php-cvs@lists.php.net Subject: Re: [PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c php_bz2.h /ext/ctype ctype.c php_ctype.h /ext/json json.c php_json.h /ext/pspell php_pspell.h pspell.c /ext/tidy php_tidy.h tidy.c /ext/zlib php_zlib.h zlib.c zlib_fopen_wrapper.c Andi, I think the idea here was to minimize memory utilization and allow the compiler to optimize the code better, something that having functions defined as statics appears to help with. On 26-Aug-06, at 11:30 AM, Andi Gutmans wrote: Why is this important? We never defined these as static. As long as you move them to the .c file (for whatever reason you have that might be justified) you really don't have to define them as static IMO. Ilia Alshanetsky Best regards, Marcus -- 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_2) /ext/bz2 bz2.c php_bz2.h /ext/ctype ctype.c php_ctype.h /ext/json json.c php_json.h /ext/pspell php_pspell.h pspell.c /ext/tidy php_tidy.h tidy.c /ext/zlib php_
Hello Andi, one thing it helps in is that having it as non static makes some compilers use an additional jump. Actually for shared dlls those functions might end up in the jump table that is going to be initialized during loading process. So infact there might be some advantage in doing it this way. Also constifying is one of our overall goals since long. And here we finally have someone willing to do the job, why not letting him do it? best regards marcus Saturday, August 26, 2006, 1:19:01 PM, you wrote: I don't think it helps. It won't inline these functions in most cases anyway, and having or not having a symbol shouldn't make a difference. I'd prefer to stick to our standards and keep all extensions the same. Who knows if/when we'll want to play around with the symbols also. It could come in handly with dlls. Andi -Original Message- From: Ilia Alshanetsky [mailto:[EMAIL PROTECTED] On Behalf Of Ilia Alshanetsky Sent: Saturday, August 26, 2006 9:59 AM To: Andi Gutmans Cc: 'Nuno Lopes'; php-cvs@lists.php.net Subject: Re: [PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c php_bz2.h /ext/ctype ctype.c php_ctype.h /ext/json json.c php_json.h /ext/pspell php_pspell.h pspell.c /ext/tidy php_tidy.h tidy.c /ext/zlib php_zlib.h zlib.c zlib_fopen_wrapper.c Andi, I think the idea here was to minimize memory utilization and allow the compiler to optimize the code better, something that having functions defined as statics appears to help with. On 26-Aug-06, at 11:30 AM, Andi Gutmans wrote: Why is this important? We never defined these as static. As long as you move them to the .c file (for whatever reason you have that might be justified) you really don't have to define them as static IMO. Ilia Alshanetsky Best regards, Marcus -- 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_2) /ext/bz2 bz2.c php_bz2.h /ext/ctype ctype.c php_ctype.h /ext/json json.c php_json.h /ext/pspell php_pspell.h pspell.c /ext/tidy php_tidy.h tidy.c /ext/zlib php
Why is this important? We never defined these as static. As long as you move them to the .c file (for whatever reason you have that might be justified) you really don't have to define them as static IMO. -Original Message- From: Nuno Lopes [mailto:[EMAIL PROTECTED] Sent: Monday, August 14, 2006 1:08 PM To: php-cvs@lists.php.net Subject: [PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c php_bz2.h /ext/ctype ctype.c php_ctype.h /ext/json json.c php_json.h /ext/pspell php_pspell.h pspell.c /ext/tidy php_tidy.h tidy.c /ext/zlib php_zlib.h zlib.c zlib_fopen_wrapper.c nlopess Mon Aug 14 20:08:18 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/bz2 bz2.c php_bz2.h /php-src/ext/ctypectype.c php_ctype.h /php-src/ext/json json.c php_json.h /php-src/ext/pspell php_pspell.h pspell.c /php-src/ext/tidy php_tidy.h tidy.c /php-src/ext/zlib php_zlib.h zlib.c zlib_fopen_wrapper.c Log: move static declaration to *.c files mroe static/const keywording -- 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_2) /ext/bz2 bz2.c php_bz2.h /ext/ctype ctype.c php_ctype.h /ext/json json.c php_json.h /ext/pspell php_pspell.h pspell.c /ext/tidy php_tidy.h tidy.c /ext/zlib php
Andi, I think the idea here was to minimize memory utilization and allow the compiler to optimize the code better, something that having functions defined as statics appears to help with. On 26-Aug-06, at 11:30 AM, Andi Gutmans wrote: Why is this important? We never defined these as static. As long as you move them to the .c file (for whatever reason you have that might be justified) you really don't have to define them as static IMO. Ilia Alshanetsky -- 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_2) /ext/bz2 bz2.c php_bz2.h /ext/ctype ctype.c php_ctype.h /ext/json json.c php_json.h /ext/pspell php_pspell.h pspell.c /ext/tidy php_tidy.h tidy.c /ext/zlib php
I don't think it helps. It won't inline these functions in most cases anyway, and having or not having a symbol shouldn't make a difference. I'd prefer to stick to our standards and keep all extensions the same. Who knows if/when we'll want to play around with the symbols also. It could come in handly with dlls. Andi -Original Message- From: Ilia Alshanetsky [mailto:[EMAIL PROTECTED] On Behalf Of Ilia Alshanetsky Sent: Saturday, August 26, 2006 9:59 AM To: Andi Gutmans Cc: 'Nuno Lopes'; php-cvs@lists.php.net Subject: Re: [PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c php_bz2.h /ext/ctype ctype.c php_ctype.h /ext/json json.c php_json.h /ext/pspell php_pspell.h pspell.c /ext/tidy php_tidy.h tidy.c /ext/zlib php_zlib.h zlib.c zlib_fopen_wrapper.c Andi, I think the idea here was to minimize memory utilization and allow the compiler to optimize the code better, something that having functions defined as statics appears to help with. On 26-Aug-06, at 11:30 AM, Andi Gutmans wrote: Why is this important? We never defined these as static. As long as you move them to the .c file (for whatever reason you have that might be justified) you really don't have to define them as static IMO. Ilia Alshanetsky -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c
tony2001Thu Aug 17 20:46:51 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/bz2bz2.c Log: fix #38485 (bz2 extension does not compile with GCC 4.1) http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.7r2=1.14.2.3.2.8diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.7 php-src/ext/bz2/bz2.c:1.14.2.3.2.8 --- php-src/ext/bz2/bz2.c:1.14.2.3.2.7 Mon Aug 14 20:08:17 2006 +++ php-src/ext/bz2/bz2.c Thu Aug 17 20:46:51 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.14.2.3.2.7 2006/08/14 20:08:17 nlopess Exp $ */ +/* $Id: bz2.c,v 1.14.2.3.2.8 2006/08/17 20:46:51 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -178,7 +178,7 @@ } /* }}} */ -static php_stream_ops php_stream_bz2io_ops = { +php_stream_ops php_stream_bz2io_ops = { php_bz2iop_write, php_bz2iop_read, php_bz2iop_close, php_bz2iop_flush, BZip2, -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c php_bz2.h /ext/ctype ctype.c php_ctype.h /ext/pspell php_pspell.h pspell.c
nlopess Mon Aug 14 14:53:23 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/bz2bz2.c php_bz2.h /php-src/ext/ctype ctype.c php_ctype.h /php-src/ext/pspell php_pspell.h pspell.c Log: a few more static keywording http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.5r2=1.14.2.3.2.6diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.5 php-src/ext/bz2/bz2.c:1.14.2.3.2.6 --- php-src/ext/bz2/bz2.c:1.14.2.3.2.5 Mon Jun 26 21:13:46 2006 +++ php-src/ext/bz2/bz2.c Mon Aug 14 14:53:23 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.14.2.3.2.5 2006/06/26 21:13:46 tony2001 Exp $ */ +/* $Id: bz2.c,v 1.14.2.3.2.6 2006/08/14 14:53:23 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -83,7 +83,7 @@ /* }}} */ -zend_function_entry bz2_functions[] = { +static zend_function_entry bz2_functions[] = { PHP_FE(bzopen, arginfo_bzopen) PHP_FE(bzread, arginfo_bzread) PHP_FALIAS(bzwrite, fwrite, NULL) @@ -167,7 +167,7 @@ } /* }}} */ -php_stream_ops php_stream_bz2io_ops = { +static php_stream_ops php_stream_bz2io_ops = { php_bz2iop_write, php_bz2iop_read, php_bz2iop_close, php_bz2iop_flush, BZip2, @@ -272,7 +272,7 @@ NULL /* rmdir */ }; -php_stream_wrapper php_stream_bzip2_wrapper = { +static php_stream_wrapper php_stream_bzip2_wrapper = { bzip2_stream_wops, NULL, 0 /* is_url */ @@ -280,14 +280,14 @@ static void php_bz2_error(INTERNAL_FUNCTION_PARAMETERS, int); -PHP_MINIT_FUNCTION(bz2) +static PHP_MINIT_FUNCTION(bz2) { php_register_url_stream_wrapper(compress.bzip2, php_stream_bzip2_wrapper TSRMLS_CC); php_stream_filter_register_factory(bzip2.*, php_bz2_filter_factory TSRMLS_CC); return SUCCESS; } -PHP_MSHUTDOWN_FUNCTION(bz2) +static PHP_MSHUTDOWN_FUNCTION(bz2) { php_unregister_url_stream_wrapper(compress.bzip2 TSRMLS_CC); php_stream_filter_unregister_factory(bzip2.* TSRMLS_CC); @@ -295,7 +295,7 @@ return SUCCESS; } -PHP_MINFO_FUNCTION(bz2) +static PHP_MINFO_FUNCTION(bz2) { php_info_print_table_start(); php_info_print_table_row(2, BZip2 Support, Enabled); @@ -307,7 +307,7 @@ /* {{{ proto string bzread(resource bz[, int length]) Reads up to length bytes from a BZip2 stream, or 1024 bytes if length is not specified */ -PHP_FUNCTION(bzread) +static PHP_FUNCTION(bzread) { zval *bz; long len = 1024; @@ -347,7 +347,7 @@ /* {{{ proto resource bzopen(string|int file|fp, string mode) Opens a new BZip2 stream */ -PHP_FUNCTION(bzopen) +static PHP_FUNCTION(bzopen) { zval**file, /* The file to open */ **mode; /* The mode to open the stream with */ @@ -435,7 +435,7 @@ /* {{{ proto int bzerrno(resource bz) Returns the error number */ -PHP_FUNCTION(bzerrno) +static PHP_FUNCTION(bzerrno) { php_bz2_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_BZ_ERRNO); } @@ -443,7 +443,7 @@ /* {{{ proto string bzerrstr(resource bz) Returns the error string */ -PHP_FUNCTION(bzerrstr) +static PHP_FUNCTION(bzerrstr) { php_bz2_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_BZ_ERRSTR); } @@ -451,7 +451,7 @@ /* {{{ proto array bzerror(resource bz) Returns the error number and error string in an associative array */ -PHP_FUNCTION(bzerror) +static PHP_FUNCTION(bzerror) { php_bz2_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_BZ_ERRBOTH); } @@ -459,7 +459,7 @@ /* {{{ proto string bzcompress(string source [, int blocksize100k [, int workfactor]]) Compresses a string into BZip2 encoded data */ -PHP_FUNCTION(bzcompress) +static PHP_FUNCTION(bzcompress) { zval**source, /* Source data to compress */ **zblock_size, /* Optional block size to use */ @@ -517,7 +517,7 @@ /* {{{ proto string bzdecompress(string source [, int small]) Decompresses BZip2 compressed data */ -PHP_FUNCTION(bzdecompress) +static PHP_FUNCTION(bzdecompress) { char *source, *dest; int source_len, error; http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/php_bz2.h?r1=1.7.2.1r2=1.7.2.1.2.1diff_format=u Index: php-src/ext/bz2/php_bz2.h diff -u php-src/ext/bz2/php_bz2.h:1.7.2.1 php-src/ext/bz2/php_bz2.h:1.7.2.1.2.1 --- php-src/ext/bz2/php_bz2.h:1.7.2.1 Sun Jan 1 12:50:00 2006 +++ php-src/ext/bz2/php_bz2.h Mon Aug 14 14:53:23 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_bz2.h,v 1.7.2.1 2006/01/01 12:50:00 sniper Exp $ */ +/* $Id: php_bz2.h,v 1.7.2.1.2.1 2006/08/14 14:53:23 nlopess Exp $ */ #ifndef PHP_BZ2_H #define PHP_BZ2_H @@ -29,16 +29,16 @@ /* Bzip2 includes */ #include bzlib.h -PHP_MINIT_FUNCTION(bz2); -PHP_MSHUTDOWN_FUNCTION(bz2);
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c php_bz2.h /ext/ctype ctype.c php_ctype.h /ext/json json.c php_json.h /ext/pspell php_pspell.h pspell.c /ext/tidy php_tidy.h tidy.c /ext/zlib php_zli
nlopess Mon Aug 14 20:08:18 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/bz2bz2.c php_bz2.h /php-src/ext/ctype ctype.c php_ctype.h /php-src/ext/json json.c php_json.h /php-src/ext/pspell php_pspell.h pspell.c /php-src/ext/tidy php_tidy.h tidy.c /php-src/ext/zlib php_zlib.h zlib.c zlib_fopen_wrapper.c Log: move static declaration to *.c files mroe static/const keywording http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.6r2=1.14.2.3.2.7diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.6 php-src/ext/bz2/bz2.c:1.14.2.3.2.7 --- php-src/ext/bz2/bz2.c:1.14.2.3.2.6 Mon Aug 14 14:53:23 2006 +++ php-src/ext/bz2/bz2.c Mon Aug 14 20:08:17 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.14.2.3.2.6 2006/08/14 14:53:23 nlopess Exp $ */ +/* $Id: bz2.c,v 1.14.2.3.2.7 2006/08/14 20:08:17 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -40,6 +40,17 @@ #define PHP_BZ_ERRSTR 1 #define PHP_BZ_ERRBOTH 2 +static PHP_MINIT_FUNCTION(bz2); +static PHP_MSHUTDOWN_FUNCTION(bz2); +static PHP_MINFO_FUNCTION(bz2); +static PHP_FUNCTION(bzopen); +static PHP_FUNCTION(bzread); +static PHP_FUNCTION(bzerrno); +static PHP_FUNCTION(bzerrstr); +static PHP_FUNCTION(bzerror); +static PHP_FUNCTION(bzcompress); +static PHP_FUNCTION(bzdecompress); + /* {{{ arginfo */ static ZEND_BEGIN_ARG_INFO_EX(arginfo_bzread, 0, 0, 1) http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/php_bz2.h?r1=1.7.2.1.2.1r2=1.7.2.1.2.2diff_format=u Index: php-src/ext/bz2/php_bz2.h diff -u php-src/ext/bz2/php_bz2.h:1.7.2.1.2.1 php-src/ext/bz2/php_bz2.h:1.7.2.1.2.2 --- php-src/ext/bz2/php_bz2.h:1.7.2.1.2.1 Mon Aug 14 14:53:23 2006 +++ php-src/ext/bz2/php_bz2.h Mon Aug 14 20:08:17 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_bz2.h,v 1.7.2.1.2.1 2006/08/14 14:53:23 nlopess Exp $ */ +/* $Id: php_bz2.h,v 1.7.2.1.2.2 2006/08/14 20:08:17 nlopess Exp $ */ #ifndef PHP_BZ2_H #define PHP_BZ2_H @@ -29,17 +29,6 @@ /* Bzip2 includes */ #include bzlib.h -static PHP_MINIT_FUNCTION(bz2); -static PHP_MSHUTDOWN_FUNCTION(bz2); -static PHP_MINFO_FUNCTION(bz2); -static PHP_FUNCTION(bzopen); -static PHP_FUNCTION(bzread); -static PHP_FUNCTION(bzerrno); -static PHP_FUNCTION(bzerrstr); -static PHP_FUNCTION(bzerror); -static PHP_FUNCTION(bzcompress); -static PHP_FUNCTION(bzdecompress); - #else #define phpext_bz2_ptr NULL #endif http://cvs.php.net/viewvc.cgi/php-src/ext/ctype/ctype.c?r1=1.34.2.3.2.2r2=1.34.2.3.2.3diff_format=u Index: php-src/ext/ctype/ctype.c diff -u php-src/ext/ctype/ctype.c:1.34.2.3.2.2 php-src/ext/ctype/ctype.c:1.34.2.3.2.3 --- php-src/ext/ctype/ctype.c:1.34.2.3.2.2 Mon Aug 14 14:53:23 2006 +++ php-src/ext/ctype/ctype.c Mon Aug 14 20:08:17 2006 @@ -40,6 +40,24 @@ /* True global resources - no need for thread safety here */ /* static int le_ctype; */ +static PHP_MINIT_FUNCTION(ctype); +static PHP_MSHUTDOWN_FUNCTION(ctype); +static PHP_RINIT_FUNCTION(ctype); +static PHP_RSHUTDOWN_FUNCTION(ctype); +static PHP_MINFO_FUNCTION(ctype); + +static PHP_FUNCTION(ctype_alnum); +static PHP_FUNCTION(ctype_alpha); +static PHP_FUNCTION(ctype_cntrl); +static PHP_FUNCTION(ctype_digit); +static PHP_FUNCTION(ctype_lower); +static PHP_FUNCTION(ctype_graph); +static PHP_FUNCTION(ctype_print); +static PHP_FUNCTION(ctype_punct); +static PHP_FUNCTION(ctype_space); +static PHP_FUNCTION(ctype_upper); +static PHP_FUNCTION(ctype_xdigit); + /* {{{ arginfo */ static ZEND_BEGIN_ARG_INFO(arginfo_ctype_alnum, 0) http://cvs.php.net/viewvc.cgi/php-src/ext/ctype/php_ctype.h?r1=1.12.2.1.2.1r2=1.12.2.1.2.2diff_format=u Index: php-src/ext/ctype/php_ctype.h diff -u php-src/ext/ctype/php_ctype.h:1.12.2.1.2.1 php-src/ext/ctype/php_ctype.h:1.12.2.1.2.2 --- php-src/ext/ctype/php_ctype.h:1.12.2.1.2.1 Mon Aug 14 14:53:23 2006 +++ php-src/ext/ctype/php_ctype.h Mon Aug 14 20:08:17 2006 @@ -33,24 +33,6 @@ #define PHP_CTYPE_API #endif -static PHP_MINIT_FUNCTION(ctype); -static PHP_MSHUTDOWN_FUNCTION(ctype); -static PHP_RINIT_FUNCTION(ctype); -static PHP_RSHUTDOWN_FUNCTION(ctype); -static PHP_MINFO_FUNCTION(ctype); - -static PHP_FUNCTION(ctype_alnum); -static PHP_FUNCTION(ctype_alpha); -static PHP_FUNCTION(ctype_cntrl); -static PHP_FUNCTION(ctype_digit); -static PHP_FUNCTION(ctype_lower); -static PHP_FUNCTION(ctype_graph); -static PHP_FUNCTION(ctype_print); -static PHP_FUNCTION(ctype_punct); -static PHP_FUNCTION(ctype_space); -static PHP_FUNCTION(ctype_upper); -static PHP_FUNCTION(ctype_xdigit); - /* Declare any global variables you may need between the BEGIN and END macros here: http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.9.2.5r2=1.9.2.6diff_format=u Index: php-src/ext/json/json.c diff -u php-src/ext/json/json.c:1.9.2.5
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c
tony2001Mon Jun 26 21:13:46 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/bz2bz2.c Log: MFH: detect empty mode string and avoid off-by-one http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.4r2=1.14.2.3.2.5diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.4 php-src/ext/bz2/bz2.c:1.14.2.3.2.5 --- php-src/ext/bz2/bz2.c:1.14.2.3.2.4 Wed Jun 21 14:38:28 2006 +++ php-src/ext/bz2/bz2.c Mon Jun 26 21:13:46 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.14.2.3.2.4 2006/06/21 14:38:28 tony2001 Exp $ */ +/* $Id: bz2.c,v 1.14.2.3.2.5 2006/06/26 21:13:46 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -205,7 +205,7 @@ if (strncasecmp(compress.bzip2://, path, 17) == 0) { path += 17; } - if (mode[0] != 'w' mode[0] != 'r' mode[1] != '\0') { + if (mode[0] == '\0' || (mode[0] != 'w' mode[0] != 'r' mode[1] != '\0')) { return NULL; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c
tony2001Wed Jun 21 12:43:27 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/bz2bz2.c Log: MFH: fix invalid read with bzopen(,) and prevent filename from being empty (which causes endless loop somewhere is libbz2) http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.1r2=1.14.2.3.2.2diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.1 php-src/ext/bz2/bz2.c:1.14.2.3.2.2 --- php-src/ext/bz2/bz2.c:1.14.2.3.2.1 Sun Jun 11 01:42:16 2006 +++ php-src/ext/bz2/bz2.c Wed Jun 21 12:43:27 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.14.2.3.2.1 2006/06/11 01:42:16 bjori Exp $ */ +/* $Id: bz2.c,v 1.14.2.3.2.2 2006/06/21 12:43:27 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -359,7 +359,7 @@ } convert_to_string_ex(mode); - if (Z_STRVAL_PP(mode)[0] != 'r' Z_STRVAL_PP(mode)[0] != 'w' Z_STRVAL_PP(mode)[1] != '\0') { + if (Z_STRLEN_PP(mode) != 1 || (Z_STRVAL_PP(mode)[0] != 'r' Z_STRVAL_PP(mode)[0] != 'w')) { php_error_docref(NULL TSRMLS_CC, E_WARNING, '%s' is not a valid mode for bzopen(). Only 'w' and 'r' are supported., Z_STRVAL_PP(mode)); RETURN_FALSE; } @@ -367,6 +367,12 @@ /* If it's not a resource its a string containing the filename to open */ if (Z_TYPE_PP(file) != IS_RESOURCE) { convert_to_string_ex(file); + + if (Z_STRLEN_PP(file) == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, filename cannot be empty); + RETURN_FALSE; + } + stream = php_stream_bz2open(NULL, Z_STRVAL_PP(file), Z_STRVAL_PP(mode), -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/bz2 bz2.c
tony2001Wed Jun 21 13:12:37 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/bz2bz2.c Log: MFH: don't try to read or write from/to a stream if it was open in different mode (leads to segfault in libbz2) http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.2r2=1.14.2.3.2.3diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.2 php-src/ext/bz2/bz2.c:1.14.2.3.2.3 --- php-src/ext/bz2/bz2.c:1.14.2.3.2.2 Wed Jun 21 12:43:27 2006 +++ php-src/ext/bz2/bz2.c Wed Jun 21 13:12:37 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.14.2.3.2.2 2006/06/21 12:43:27 tony2001 Exp $ */ +/* $Id: bz2.c,v 1.14.2.3.2.3 2006/06/21 13:12:37 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -384,6 +384,18 @@ php_stream_from_zval(stream, file); + if (!memchr(stream-mode, Z_STRVAL_PP(mode)[0], strlen(stream-mode))) { + switch (Z_STRVAL_PP(mode)[0]) { + case 'r': + php_error_docref(NULL TSRMLS_CC, E_WARNING, cannot read from a stream opened in write only mode); + break; + case 'w': + php_error_docref(NULL TSRMLS_CC, E_WARNING, cannot write to a stream opened in read only mode); + break; + } + RETURN_FALSE; + } + if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_FD, (void *) fd, REPORT_ERRORS)) { 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_2) /ext/bz2 bz2.c /ext/bz2/tests 001.phpt 002.phpt
tony2001Wed Jun 21 14:38:28 2006 UTC Added files: (Branch: PHP_5_2) /php-src/ext/bz2/tests 001.phpt 002.phpt Modified files: /php-src/ext/bz2bz2.c Log: MFH: improve check for stream mode, add tests http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.14.2.3.2.3r2=1.14.2.3.2.4diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.14.2.3.2.3 php-src/ext/bz2/bz2.c:1.14.2.3.2.4 --- php-src/ext/bz2/bz2.c:1.14.2.3.2.3 Wed Jun 21 13:12:37 2006 +++ php-src/ext/bz2/bz2.c Wed Jun 21 14:38:28 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.14.2.3.2.3 2006/06/21 13:12:37 tony2001 Exp $ */ +/* $Id: bz2.c,v 1.14.2.3.2.4 2006/06/21 14:38:28 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -381,19 +381,39 @@ } else { /* If it is a resource, than its a stream resource */ int fd; + int stream_mode_len; php_stream_from_zval(stream, file); + stream_mode_len = strlen(stream-mode); + + if (stream_mode_len != 1 !(stream_mode_len == 2 memchr(stream-mode, 'b', 2))) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, cannot use stream opened in mode '%s', stream-mode); + RETURN_FALSE; + } else if (stream_mode_len == 1 stream-mode[0] != 'r' stream-mode[0] != 'w' stream-mode[0] != 'a' stream-mode[0] != 'x') { + php_error_docref(NULL TSRMLS_CC, E_WARNING, cannot use stream opened in mode '%s', stream-mode); + RETURN_FALSE; + } - if (!memchr(stream-mode, Z_STRVAL_PP(mode)[0], strlen(stream-mode))) { - switch (Z_STRVAL_PP(mode)[0]) { - case 'r': + switch(Z_STRVAL_PP(mode)[0]) { + case 'r': + /* only r and rb are supported */ + if (stream-mode[0] != Z_STRVAL_PP(mode)[0] !(stream_mode_len == 2 stream-mode[1] != Z_STRVAL_PP(mode)[0])) { php_error_docref(NULL TSRMLS_CC, E_WARNING, cannot read from a stream opened in write only mode); - break; - case 'w': + RETURN_FALSE; + } + break; + case 'w': + /* support only w(b), a(b), x(b) */ + if (stream-mode[0] != Z_STRVAL_PP(mode)[0] !(stream_mode_len == 2 stream-mode[1] != Z_STRVAL_PP(mode)[0]) +stream-mode[0] != 'a' !(stream_mode_len == 2 stream-mode[1] != 'a') +stream-mode[0] != 'x' !(stream_mode_len == 2 stream-mode[1] != 'x')) { php_error_docref(NULL TSRMLS_CC, E_WARNING, cannot write to a stream opened in read only mode); - break; - } - RETURN_FALSE; + RETURN_FALSE; + } + break; + default: + /* not reachable */ + break; } if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_FD, (void *) fd, REPORT_ERRORS)) { http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/tests/001.phpt?view=markuprev=1.1 Index: php-src/ext/bz2/tests/001.phpt +++ php-src/ext/bz2/tests/001.phpt --TEST-- bzopen() and invalid parameters --FILE-- ?php var_dump(bzopen()); var_dump(bzopen(, )); var_dump(bzopen(, r)); var_dump(bzopen(, w)); var_dump(bzopen(, x)); var_dump(bzopen(, rw)); var_dump(bzopen(no_such_file, r)); $fp = fopen(__FILE__,r); var_dump(bzopen($fp, r)); echo Done\n; ? --EXPECTF-- Warning: Wrong parameter count for bzopen() in %s on line %d NULL Warning: bzopen(): '' is not a valid mode for bzopen(). Only 'w' and 'r' are supported. in %s on line %d bool(false) Warning: bzopen(): filename cannot be empty in %s on line %d bool(false) Warning: bzopen(): filename cannot be empty in %s on line %d bool(false) Warning: bzopen(): 'x' is not a valid mode for bzopen(). Only 'w' and 'r' are supported. in %s on line %d bool(false) Warning: bzopen(): 'rw' is not a valid mode for bzopen(). Only 'w' and 'r' are supported. in %s on line %d bool(false) Warning: bzopen(no_such_file): failed to open stream: No such file or directory in %s on line %d bool(false) resource(%d) of type (stream) Done http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/tests/002.phpt?view=markuprev=1.1 Index: php-src/ext/bz2/tests/002.phpt +++