[PHP-CVS] cvs: php-src /ext/bz2 bz2.c
tony2001Wed Jul 23 08:56:00 2008 UTC Modified files: /php-src/ext/bz2bz2.c Log: 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.35r2=1.36diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.35 php-src/ext/bz2/bz2.c:1.36 --- php-src/ext/bz2/bz2.c:1.35 Mon Dec 31 07:12:07 2007 +++ php-src/ext/bz2/bz2.c Wed Jul 23 08:55:59 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.35 2007/12/31 07:12:07 sebastian Exp $ */ +/* $Id: bz2.c,v 1.36 2008/07/23 08:55:59 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 /ext/bz2 bz2.c
tony2001Mon Dec 25 20:03:20 2006 UTC Modified files: /php-src/ext/bz2bz2.c Log: improve check for overflow http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.30r2=1.31diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.30 php-src/ext/bz2/bz2.c:1.31 --- php-src/ext/bz2/bz2.c:1.30 Tue Oct 31 22:13:09 2006 +++ php-src/ext/bz2/bz2.c Mon Dec 25 20:03:20 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.30 2006/10/31 22:13:09 nlopess Exp $ */ +/* $Id: bz2.c,v 1.31 2006/12/25 20:03:20 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
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c /ext/gd gd.c
nlopess Tue Oct 31 22:13:10 2006 UTC Modified files: /php-src/ext/bz2bz2.c /php-src/ext/gd gd.c Log: cleaning some warnings (char* - zstr) http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.29r2=1.30diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.29 php-src/ext/bz2/bz2.c:1.30 --- php-src/ext/bz2/bz2.c:1.29 Sun Oct 8 13:34:20 2006 +++ php-src/ext/bz2/bz2.c Tue Oct 31 22:13:09 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.29 2006/10/08 13:34:20 bjori Exp $ */ +/* $Id: bz2.c,v 1.30 2006/10/31 22:13:09 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -477,7 +477,7 @@ Compresses a string into BZip2 encoded data */ static PHP_FUNCTION(bzcompress) { - char*source;/* String to compress */ + zstrsource; /* String to compress */ int source_len; zend_uchar source_type; longblock_size = 4, /* Block size for compression algorithm */ @@ -498,14 +498,14 @@ dest = emalloc(dest_len + 1); if (source_type == IS_UNICODE) { - source = zend_unicode_to_ascii((UChar*)source, source_len TSRMLS_CC); - if (!source) { + source.s = zend_unicode_to_ascii(source.u, source_len TSRMLS_CC); + if (!source.s) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received); RETURN_FALSE; } } - error = BZ2_bzBuffToBuffCompress(dest, dest_len, source, source_len, block_size, 0, work_factor); + error = BZ2_bzBuffToBuffCompress(dest, dest_len, source.s, source_len, block_size, 0, work_factor); if (error != BZ_OK) { efree(dest); RETVAL_LONG(error); @@ -520,7 +520,7 @@ } if (source_type == IS_UNICODE) { - efree(source); + efree(source.s); } } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/gd/gd.c?r1=1.360r2=1.361diff_format=u Index: php-src/ext/gd/gd.c diff -u php-src/ext/gd/gd.c:1.360 php-src/ext/gd/gd.c:1.361 --- php-src/ext/gd/gd.c:1.360 Wed Oct 18 16:04:25 2006 +++ php-src/ext/gd/gd.c Tue Oct 31 22:13:09 2006 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: gd.c,v 1.360 2006/10/18 16:04:25 bjori Exp $ */ +/* $Id: gd.c,v 1.361 2006/10/31 22:13:09 nlopess Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -3205,7 +3205,7 @@ zval *IM; long size, x, y, col; zend_uchar str_type; - char *str; + zstr str; int str_len, i; gdImagePtr im; gdFontPtr font; @@ -3215,8 +3215,8 @@ } if (str_type == IS_UNICODE) { - str = zend_unicode_to_ascii((UChar*)str, str_len TSRMLS_CC); - if (!str) { + str.s = zend_unicode_to_ascii(str.u, str_len TSRMLS_CC); + if (!str.s) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received. Consider using the TTF functions for Unicode output); RETURN_FALSE; } @@ -3228,21 +3228,21 @@ switch (mode) { case 0: - gdImageChar(im, font, x, y, (int) ((unsigned char)str[0]), col); + gdImageChar(im, font, x, y, (int) ((unsigned char)str.s[0]), col); break; case 1: - php_gdimagecharup(im, font, x, y, (int) ((unsigned char)str[0]), col); + php_gdimagecharup(im, font, x, y, (int) ((unsigned char)str.s[0]), col); break; case 2: for (i = 0; (i str_len); i++) { - gdImageChar(im, font, x, y, (int) ((unsigned char)str[i]), col); + gdImageChar(im, font, x, y, (int) ((unsigned char)str.s[i]), col); x += font-w; } break; case 3: { for (i = 0; (i str_len); i++) { /* php_gdimagecharup(im, font, x, y, (int) str[i], col); */ - gdImageCharUp(im, font, x, y, (int) ((unsigned char)str[i]), col); + gdImageCharUp(im, font, x, y, (int) ((unsigned char)str.s[i]), col); y -= font-w; } break; @@ -3250,7 +3250,7 @@ } if (str_type == IS_UNICODE) { - efree(str); +
Re: [PHP-CVS] cvs: php-src /ext/bz2 bz2.c bz2_filter.c /ext/bz2/tests 001.phpt /ext/calendar calendar.c /ext/calendar/tests cal_info.phpt /ext/curl interface.c /ext/date php_date.c /ext/date/tes
Oh Lord, did we really need to touch almost every file to remove a bloody period from error messages? -Andrei On Oct 8, 2006, at 6:34 AM, Hannes Magnusson wrote: bjori Sun Oct 8 13:34:25 2006 UTC Modified files: /php-src/ext/bz2bz2.c bz2_filter.c /php-src/ext/bz2/tests 001.phpt /php-src/ext/calendar calendar.c /php-src/ext/calendar/tests cal_info.phpt /php-src/ext/curl interface.c /php-src/ext/date php_date.c /php-src/ext/date/tests 005.phpt /php-src/ext/dbase dbf_rec.c /php-src/ext/domdocument.c node.c /php-src/ext/fbsql php_fbsql.c /php-src/ext/ftpftp.c php_ftp.c /php-src/ext/iconv iconv.c /php-src/ext/imap php_imap.c /php-src/ext/ldap ldap.c /php-src/ext/mbstring mbstring.c /php-src/ext/mcrypt mcrypt.c /php-src/ext/mcrypt/tests bug35496.phpt /php-src/ext/mime_magic mime_magic.c /php-src/ext/mysql php_mysql.c /php-src/ext/mysqli mysqli_api.c /php-src/ext/oci8 oci8_lob.c /php-src/ext/opensslopenssl.c /php-src/ext/pcre php_pcre.c /php-src/ext/pcre/tests preg_replace2.phpt /php-src/ext/pdopdo_dbh.c /php-src/ext/pspell pspell.c /php-src/ext/pspell/tests 003.phpt 005.phpt /php-src/ext/recode recode.c /php-src/ext/sessionsession.c /php-src/ext/session/tests 014.phpt /php-src/ext/soap soap.c /php-src/ext/soap/tests/bugsbug31755.phpt /php-src/ext/socketssockets.c /php-src/ext/sqlite sqlite.c /php-src/ext/standard array.c basic_functions.c browscap.c dl.c exec.c file.c filters.c http.c http_fopen_wrapper.c image.c streamsfuncs.c string.c uniqid.c url.c uuencode.c var.c /php-src/ext/sybase php_sybase_db.c /php-src/ext/sybase_ct php_sybase_ct.c /php-src/ext/sysvmsgsysvmsg.c /php-src/ext/tidy tidy.c /php-src/ext/wddx wddx.c /php-src/ext/xmlxml.c /php-src/ext/xmlreader php_xmlreader.c /php-src/ext/xslxsltprocessor.c /php-src/ext/zlib zlib_filter.c /php-src/main/streams filter.c streams.c unicode_filter.c userspace.c Log: Error message clean up (patch by Matt W (php_lists -AT- realpain.com)) bjori-20061008133425.txt-- 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 /ext/bz2 bz2.c bz2_filter.c /ext/bz2/tests 001.phpt /ext/calendar calendar.c /ext/calendar/tests cal_info.phpt /ext/curl interface.c /ext/date php_date.c /ext/date/tests 005
On 10/9/06, Andrei Zmievski [EMAIL PROTECTED] wrote: Oh Lord, did we really need to touch almost every file to remove a bloody period from error messages? I'll gladly revert if it helps you in any way... -Hannes On Oct 8, 2006, at 6:34 AM, Hannes Magnusson wrote: bjori Sun Oct 8 13:34:25 2006 UTC Modified files: /php-src/ext/bz2 bz2.c bz2_filter.c /php-src/ext/bz2/tests001.phpt /php-src/ext/calendar calendar.c /php-src/ext/calendar/tests cal_info.phpt /php-src/ext/curl interface.c /php-src/ext/date php_date.c /php-src/ext/date/tests 005.phpt /php-src/ext/dbasedbf_rec.c /php-src/ext/dom document.c node.c /php-src/ext/fbsqlphp_fbsql.c /php-src/ext/ftp ftp.c php_ftp.c /php-src/ext/iconviconv.c /php-src/ext/imap php_imap.c /php-src/ext/ldap ldap.c /php-src/ext/mbstring mbstring.c /php-src/ext/mcrypt mcrypt.c /php-src/ext/mcrypt/tests bug35496.phpt /php-src/ext/mime_magic mime_magic.c /php-src/ext/mysqlphp_mysql.c /php-src/ext/mysqli mysqli_api.c /php-src/ext/oci8 oci8_lob.c /php-src/ext/openssl openssl.c /php-src/ext/pcre php_pcre.c /php-src/ext/pcre/tests preg_replace2.phpt /php-src/ext/pdo pdo_dbh.c /php-src/ext/pspell pspell.c /php-src/ext/pspell/tests 003.phpt 005.phpt /php-src/ext/recode recode.c /php-src/ext/session session.c /php-src/ext/session/tests014.phpt /php-src/ext/soap soap.c /php-src/ext/soap/tests/bugs bug31755.phpt /php-src/ext/sockets sockets.c /php-src/ext/sqlite sqlite.c /php-src/ext/standard array.c basic_functions.c browscap.c dl.c exec.c file.c filters.c http.c http_fopen_wrapper.c image.c streamsfuncs.c string.c uniqid.c url.c uuencode.c var.c /php-src/ext/sybase php_sybase_db.c /php-src/ext/sybase_ctphp_sybase_ct.c /php-src/ext/sysvmsg sysvmsg.c /php-src/ext/tidy tidy.c /php-src/ext/wddx wddx.c /php-src/ext/xml xml.c /php-src/ext/xmlreaderphp_xmlreader.c /php-src/ext/xsl xsltprocessor.c /php-src/ext/zlib zlib_filter.c /php-src/main/streams filter.c streams.c unicode_filter.c userspace.c Log: Error message clean up (patch by Matt W (php_lists -AT- realpain.com)) bjori-20061008133425.txt-- 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
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c php_bz2.h /ext/ctype ctype.c php_ctype.h /ext/pspell php_pspell.h pspell.c
bjori Sun Oct 8 00:05:17 2006 UTC Modified files: /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: MFB (move static keywording from .h to .c) http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.27r2=1.28diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.27 php-src/ext/bz2/bz2.c:1.28 --- php-src/ext/bz2/bz2.c:1.27 Thu Oct 5 21:28:18 2006 +++ php-src/ext/bz2/bz2.c Sun Oct 8 00:05:17 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.27 2006/10/05 21:28:18 pollita Exp $ */ +/* $Id: bz2.c,v 1.28 2006/10/08 00:05:17 bjori 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.9r2=1.10diff_format=u Index: php-src/ext/bz2/php_bz2.h diff -u php-src/ext/bz2/php_bz2.h:1.9 php-src/ext/bz2/php_bz2.h:1.10 --- php-src/ext/bz2/php_bz2.h:1.9 Mon Aug 14 14:54:19 2006 +++ php-src/ext/bz2/php_bz2.h Sun Oct 8 00:05:17 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_bz2.h,v 1.9 2006/08/14 14:54:19 nlopess Exp $ */ +/* $Id: php_bz2.h,v 1.10 2006/10/08 00:05:17 bjori 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.41r2=1.42diff_format=u Index: php-src/ext/ctype/ctype.c diff -u php-src/ext/ctype/ctype.c:1.41 php-src/ext/ctype/ctype.c:1.42 --- php-src/ext/ctype/ctype.c:1.41 Mon Aug 14 14:54:19 2006 +++ php-src/ext/ctype/ctype.c Sun Oct 8 00:05:17 2006 @@ -40,6 +40,20 @@ /* True global resources - no need for thread safety here */ /* static int le_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.14r2=1.15diff_format=u Index: php-src/ext/ctype/php_ctype.h diff -u php-src/ext/ctype/php_ctype.h:1.14 php-src/ext/ctype/php_ctype.h:1.15 --- php-src/ext/ctype/php_ctype.h:1.14 Mon Aug 14 14:54:19 2006 +++ php-src/ext/ctype/php_ctype.h Sun Oct 8 00:05: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/pspell/php_pspell.h?r1=1.17r2=1.18diff_format=u Index: php-src/ext/pspell/php_pspell.h diff -u php-src/ext/pspell/php_pspell.h:1.17 php-src/ext/pspell/php_pspell.h:1.18 --- php-src/ext/pspell/php_pspell.h:1.17Mon Aug 14 14:54:19 2006 +++ php-src/ext/pspell/php_pspell.h Sun Oct 8 00:05:17 2006 @@ -16,35 +16,13 @@ +--+ */ -/* $Id: php_pspell.h,v 1.17 2006/08/14 14:54:19 nlopess Exp $ */ +/* $Id: php_pspell.h,v 1.18 2006/10/08 00:05:17 bjori Exp $ */ #ifndef _PSPELL_H #define _PSPELL_H #if HAVE_PSPELL extern zend_module_entry pspell_module_entry; #define pspell_module_ptr
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c /ext/bz2/tests 001.phpt 004.phpt 005.phpt
pollita Thu Oct 5 21:28:19 2006 UTC Modified files: /php-src/ext/bz2bz2.c /php-src/ext/bz2/tests 001.phpt 004.phpt 005.phpt Log: Updated for PHP6 http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.26r2=1.27diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.26 php-src/ext/bz2/bz2.c:1.27 --- php-src/ext/bz2/bz2.c:1.26 Wed Aug 30 18:40:01 2006 +++ php-src/ext/bz2/bz2.c Thu Oct 5 21:28:18 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.26 2006/08/30 18:40:01 iliaa Exp $ */ +/* $Id: bz2.c,v 1.27 2006/10/05 21:28:18 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -305,7 +305,7 @@ php_info_print_table_end(); } -/* {{{ proto string bzread(resource bz[, int length]) +/* {{{ proto string bzread(resource bz[, int length]) U Reads up to length bytes from a BZip2 stream, or 1024 bytes if length is not specified */ static PHP_FUNCTION(bzread) { @@ -324,54 +324,64 @@ RETURN_FALSE; } - Z_STRVAL_P(return_value) = emalloc(len + 1); - Z_STRLEN_P(return_value) = php_stream_read(stream, Z_STRVAL_P(return_value), len); - - if (Z_STRLEN_P(return_value) 0) { - efree(Z_STRVAL_P(return_value)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, could not read valid bz2 data from stream); - RETURN_FALSE; - } - - Z_STRVAL_P(return_value)[Z_STRLEN_P(return_value)] = 0; + if (stream-readbuf_type == IS_UNICODE) { + int buflen = len; + UChar *buf = php_stream_read_unicode_chars(stream, buflen); + + if (!buf) { + /* For BC */ + RETURN_EMPTY_UNICODE(); + } - Z_TYPE_P(return_value) = IS_STRING; + RETURN_UNICODEL(buf, buflen, 0); + } else { /* IS_STRING */ + char *buf = emalloc(len + 1); + int buflen = php_stream_read(stream, buf, len); + + if (!buflen) { + efree(buf); + RETURN_EMPTY_STRING(); + } + buf[buflen] = 0; + RETURN_STRINGL(buf, buflen, 0); + } } /* }}} */ -/* {{{ proto resource bzopen(string|int file|fp, string mode) +/* {{{ proto resource bzopen(string|int file|fp, string mode) U Opens a new BZip2 stream */ static PHP_FUNCTION(bzopen) { - zval**file, /* The file to open */ - **mode; /* The mode to open the stream with */ + zval**file; /* The file to open */ + char*mode;/* The mode to open the stream with */ + int mode_len; BZFILE *bz; /* The compressed file stream */ php_stream *stream = NULL; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, file, mode) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Zs, file, mode, mode_len) == FAILURE) { + return; } - convert_to_string_ex(mode); - 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)); + if (mode_len != 1 || (mode[0] != 'r' 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., mode); RETURN_FALSE; } /* 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); + char *filename; + int filename_len; + + if (FAILURE == php_stream_path_param_encode(file, filename, filename_len, REPORT_ERRORS, FG(default_context))) { + RETURN_FALSE; + } - if (Z_STRLEN_PP(file) == 0) { + if (filename_len == 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), - REPORT_ERRORS, - NULL); + stream = php_stream_bz2open(NULL, filename, mode, REPORT_ERRORS, NULL); } else { /* If it is a resource, than its a stream resource */ int fd; @@ -388,17 +398,17 @@
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c
iliaa Wed Aug 30 18:40:01 2006 UTC Modified files: /php-src/ext/bz2bz2.c Log: Fixed build with gcc 4.1.1 http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.25r2=1.26diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.25 php-src/ext/bz2/bz2.c:1.26 --- php-src/ext/bz2/bz2.c:1.25 Mon Aug 14 14:54:19 2006 +++ php-src/ext/bz2/bz2.c Wed Aug 30 18:40:01 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.25 2006/08/14 14:54:19 nlopess Exp $ */ +/* $Id: bz2.c,v 1.26 2006/08/30 18:40:01 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -167,7 +167,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 /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:54:19 2006 UTC Modified files: /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: MFB: a few more static keywording http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.24r2=1.25diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.24 php-src/ext/bz2/bz2.c:1.25 --- php-src/ext/bz2/bz2.c:1.24 Mon Jun 26 21:13:22 2006 +++ php-src/ext/bz2/bz2.c Mon Aug 14 14:54:19 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.24 2006/06/26 21:13:22 tony2001 Exp $ */ +/* $Id: bz2.c,v 1.25 2006/08/14 14:54:19 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; @@ -341,7 +341,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 */ @@ -429,7 +429,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); } @@ -437,7 +437,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); } @@ -445,7 +445,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); } @@ -453,7 +453,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 */ @@ -511,7 +511,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.8r2=1.9diff_format=u Index: php-src/ext/bz2/php_bz2.h diff -u php-src/ext/bz2/php_bz2.h:1.8 php-src/ext/bz2/php_bz2.h:1.9 --- php-src/ext/bz2/php_bz2.h:1.8 Sun Jan 1 13:09:48 2006 +++ php-src/ext/bz2/php_bz2.h Mon Aug 14 14:54:19 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_bz2.h,v 1.8 2006/01/01 13:09:48 sniper Exp $ */ +/* $Id: php_bz2.h,v 1.9 2006/08/14 14:54:19 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_MINFO_FUNCTION(bz2); -PHP_FUNCTION(bzopen); -PHP_FUNCTION(bzread); -PHP_FUNCTION(bzerrno); -PHP_FUNCTION(bzerrstr);
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c
tony2001Mon Jun 26 21:13:22 2006 UTC Modified files: /php-src/ext/bz2bz2.c Log: detect empty mode string and avoid off-by-one http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.23r2=1.24diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.23 php-src/ext/bz2/bz2.c:1.24 --- php-src/ext/bz2/bz2.c:1.23 Wed Jun 21 14:38:06 2006 +++ php-src/ext/bz2/bz2.c Mon Jun 26 21:13:22 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.23 2006/06/21 14:38:06 tony2001 Exp $ */ +/* $Id: bz2.c,v 1.24 2006/06/26 21:13:22 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 /ext/bz2 bz2.c
tony2001Wed Jun 21 12:42:50 2006 UTC Modified files: /php-src/ext/bz2bz2.c Log: fix invalid read with bzopen(,) and prevent filename from being empty (which causes endless loop somewhere is libbz2) tests will follow http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.20r2=1.21diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.20 php-src/ext/bz2/bz2.c:1.21 --- php-src/ext/bz2/bz2.c:1.20 Sat Jun 10 22:59:39 2006 +++ php-src/ext/bz2/bz2.c Wed Jun 21 12:42:50 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.20 2006/06/10 22:59:39 bjori Exp $ */ +/* $Id: bz2.c,v 1.21 2006/06/21 12:42:50 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -353,7 +353,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; } @@ -361,6 +361,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 /ext/bz2 bz2.c
tony2001Wed Jun 21 13:12:00 2006 UTC Modified files: /php-src/ext/bz2bz2.c Log: 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.21r2=1.22diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.21 php-src/ext/bz2/bz2.c:1.22 --- php-src/ext/bz2/bz2.c:1.21 Wed Jun 21 12:42:50 2006 +++ php-src/ext/bz2/bz2.c Wed Jun 21 13:12:00 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.21 2006/06/21 12:42:50 tony2001 Exp $ */ +/* $Id: bz2.c,v 1.22 2006/06/21 13:12:00 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -378,6 +378,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 /ext/bz2 bz2.c /ext/bz2/tests 001.phpt 002.phpt
tony2001Wed Jun 21 14:38:06 2006 UTC Added files: /php-src/ext/bz2/tests 001.phpt 002.phpt Modified files: /php-src/ext/bz2bz2.c Log: improve check for stream mode, add tests http://cvs.php.net/viewvc.cgi/php-src/ext/bz2/bz2.c?r1=1.22r2=1.23diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.22 php-src/ext/bz2/bz2.c:1.23 --- php-src/ext/bz2/bz2.c:1.22 Wed Jun 21 13:12:00 2006 +++ php-src/ext/bz2/bz2.c Wed Jun 21 14:38:06 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.22 2006/06/21 13:12:00 tony2001 Exp $ */ +/* $Id: bz2.c,v 1.23 2006/06/21 14:38:06 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -375,19 +375,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 +++ php-src/ext/bz2/tests/002.phpt --TEST-- bzopen() using fd opened in wrong mode
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c /ext/dba dba.c /ext/exif exif.c /ext/ftp php_ftp.c /ext/gd gd.c /ext/hash hash.c hash_md.c hash_sha.c /ext/imap php_imap.c /ext/libxml libxml.c /ext/mime_
andiSun Feb 19 04:29:42 2006 UTC Modified files: /php-src/ext/bz2bz2.c /php-src/ext/dbadba.c /php-src/ext/exif exif.c /php-src/ext/ftpphp_ftp.c /php-src/ext/gd gd.c /php-src/ext/hash hash.c hash_md.c hash_sha.c /php-src/ext/imap php_imap.c /php-src/ext/libxml libxml.c /php-src/ext/mime_magic mime_magic.c /php-src/ext/ming ming.c /php-src/ext/oci8 oci8_interface.c /php-src/ext/pdopdo_dbh.c /php-src/ext/pgsql pgsql.c /php-src/ext/soap php_http.c php_xml.c /php-src/ext/splspl_directory.c /php-src/ext/standard basic_functions.c dir.c file.c fsock.c http_fopen_wrapper.c image.c md5.c proc_open.c sha1.c streamsfuncs.c /php-src/ext/tidy tidy.c /php-src/ext/xmlwriter php_xmlwriter.c /php-src/ext/zlib zlib.c /php-src/main main.c network.c /php-src/main/streams streams.c Log: - Get rid of using ENFORCE_SAFE_MODE. http://cvs.php.net/viewcvs.cgi/php-src/ext/bz2/bz2.c?r1=1.17r2=1.18diff_format=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.17 php-src/ext/bz2/bz2.c:1.18 --- php-src/ext/bz2/bz2.c:1.17 Sun Jan 1 13:09:48 2006 +++ php-src/ext/bz2/bz2.c Sun Feb 19 04:29:40 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.17 2006/01/01 13:09:48 sniper Exp $ */ +/* $Id: bz2.c,v 1.18 2006/02/19 04:29:40 andi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -327,7 +327,7 @@ stream = php_stream_bz2open(NULL, Z_STRVAL_PP(file), Z_STRVAL_PP(mode), - ENFORCE_SAFE_MODE | REPORT_ERRORS, + REPORT_ERRORS, NULL); } else { /* If it is a resource, than its a stream resource */ http://cvs.php.net/viewcvs.cgi/php-src/ext/dba/dba.c?r1=1.115r2=1.116diff_format=u Index: php-src/ext/dba/dba.c diff -u php-src/ext/dba/dba.c:1.115 php-src/ext/dba/dba.c:1.116 --- php-src/ext/dba/dba.c:1.115 Sun Jan 1 13:09:49 2006 +++ php-src/ext/dba/dba.c Sun Feb 19 04:29:40 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: dba.c,v 1.115 2006/01/01 13:09:49 sniper Exp $ */ +/* $Id: dba.c,v 1.116 2006/02/19 04:29:40 andi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -753,7 +753,7 @@ /* when in read only mode try to use existing .lck file first */ /* do not log errors for .lck file while in read ony mode on .lck file */ lock_file_mode = rb; - info-lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|IGNORE_PATH|ENFORCE_SAFE_MODE|persistent_flag, opened_path); + info-lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|IGNORE_PATH|persistent_flag, opened_path); } if (!info-lock.fp) { /* when not in read mode or failed to open .lck file read only. now try again in create(write) mode and log errors */ @@ -768,7 +768,7 @@ } } if (!info-lock.fp) { - info-lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE|persistent_flag, opened_path); + info-lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|persistent_flag, opened_path); if (info-lock.fp) { if (lock_dbf) { /* replace the path info with the real path of the opened file */ @@ -806,7 +806,7 @@ if (info-lock.fp lock_dbf) { info-fp = info-lock.fp; /* use the same stream for locking and database access */ } else { - info-fp = php_stream_open_wrapper(info-path, file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE|persistent_flag, NULL); + info-fp = php_stream_open_wrapper(info-path, file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|persistent_flag, NULL); } if (!info-fp) { dba_close(info TSRMLS_CC); http://cvs.php.net/viewcvs.cgi/php-src/ext/exif/exif.c?r1=1.177r2=1.178diff_format=u
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c
iliaa Tue Oct 25 11:52:11 2005 EDT Modified files: /php-src/ext/bz2bz2.c Log: Fixed bug #34968 (bz2 extension fails on to build on some win32 setups). http://cvs.php.net/diff.php/php-src/ext/bz2/bz2.c?r1=1.14r2=1.15ty=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.14 php-src/ext/bz2/bz2.c:1.15 --- php-src/ext/bz2/bz2.c:1.14 Wed Aug 3 10:06:39 2005 +++ php-src/ext/bz2/bz2.c Tue Oct 25 11:52:08 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.14 2005/08/03 14:06:39 sniper Exp $ */ +/* $Id: bz2.c,v 1.15 2005/10/25 15:52:08 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -441,7 +441,7 @@ char *source, *dest; int source_len, error; long small = 0; -#if defined(PHP_WIN32) _MSC_VER 1300 +#if defined(PHP_WIN32) unsigned __int64 size = 0; #else unsigned long long size = 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/bz2 bz2.c
Stefan Esser wrote: Hi Ilia, it is me again -size = (bzs.total_out_hi32 32) + bzs.total_out_lo32; +size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32; while this maybe silence the compiler I do not see how this can be mathematically the same ;) Stefan That's actually the correct implementation of the code... bz2 works by setting hi32 + 1 when lo32 overflows. So 1 in hi32 == INT_MAX, which means total size is hi32 * INT_MAX + lo32. The documentation claimed it was hi32 32, but that's not really the case. Ilia -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c
iliaa Thu Jun 9 12:13:14 2005 EDT Modified files: /php-src/ext/bz2bz2.c Log: Fixed compiler warning. http://cvs.php.net/diff.php/php-src/ext/bz2/bz2.c?r1=1.11r2=1.12ty=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.11 php-src/ext/bz2/bz2.c:1.12 --- php-src/ext/bz2/bz2.c:1.11 Mon Jun 6 12:30:46 2005 +++ php-src/ext/bz2/bz2.c Thu Jun 9 12:13:14 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.11 2005/06/06 16:30:46 iliaa Exp $ */ +/* $Id: bz2.c,v 1.12 2005/06/09 16:13:14 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -465,13 +465,13 @@ while ((error = BZ2_bzDecompress(bzs)) == BZ_OK bzs.avail_in 0) { /* compression is better then 2:1, need to allocate more memory */ bzs.avail_out = source_len; - size = (bzs.total_out_hi32 32) + bzs.total_out_lo32; + size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32; dest = erealloc(dest, size + bzs.avail_out + 1); bzs.next_out = dest + size; } if (error == BZ_STREAM_END || error == BZ_OK) { - size = (bzs.total_out_hi32 32) + bzs.total_out_lo32; + size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32; dest = erealloc(dest, size + 1); dest[size] = '\0'; RETVAL_STRINGL(dest, size, 0); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/bz2 bz2.c
Hi Ilia, it is me again - size = (bzs.total_out_hi32 32) + bzs.total_out_lo32; + size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32; while this maybe silence the compiler I do not see how this can be mathematically the same ;) Stefan -- -- Stefan Esser [EMAIL PROTECTED] Hardened-PHP Project http://www.hardened-php.net/ GPG-Keygpg --keyserver pgp.mit.edu --recv-key 0x15ABDA78 Key fingerprint 7806 58C8 CFA8 CE4A 1C2C 57DD 4AE1 795E 15AB DA78 -- -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c
iliaa Mon Jun 6 12:30:49 2005 EDT Modified files: /php-src/ext/bz2bz2.c Log: Better storage size for output length. # Thanks to Stefan for noticing the problem. http://cvs.php.net/diff.php/php-src/ext/bz2/bz2.c?r1=1.10r2=1.11ty=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.10 php-src/ext/bz2/bz2.c:1.11 --- php-src/ext/bz2/bz2.c:1.10 Sun Jun 5 14:04:20 2005 +++ php-src/ext/bz2/bz2.c Mon Jun 6 12:30:46 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.10 2005/06/05 18:04:20 iliaa Exp $ */ +/* $Id: bz2.c,v 1.11 2005/06/06 16:30:46 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -441,7 +441,7 @@ char *source, *dest; int source_len, error; long small = 0; - unsigned int size = 0; + unsigned long long size = 0; bz_stream bzs; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, source, source_len, small)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c
iliaa Sun Jun 5 14:04:21 2005 EDT Modified files: /php-src/ext/bz2bz2.c Log: Fixed bug #33070 (Improved performance of bzdecompress() by several orders of magnitude). http://cvs.php.net/diff.php/php-src/ext/bz2/bz2.c?r1=1.9r2=1.10ty=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.9 php-src/ext/bz2/bz2.c:1.10 --- php-src/ext/bz2/bz2.c:1.9 Sat Mar 19 08:56:00 2005 +++ php-src/ext/bz2/bz2.c Sun Jun 5 14:04:20 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.9 2005/03/19 13:56:00 tony2001 Exp $ */ +/* $Id: bz2.c,v 1.10 2005/06/05 18:04:20 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -40,9 +40,6 @@ #define PHP_BZ_ERRSTR 1 #define PHP_BZ_ERRBOTH 2 -/* Blocksize of the decompression buffer */ -#define PHP_BZ_DECOMPRESS_SIZE 4096 - function_entry bz2_functions[] = { PHP_FE(bzopen, NULL) PHP_FE(bzread, NULL) @@ -441,56 +438,49 @@ Decompresses BZip2 compressed data */ PHP_FUNCTION(bzdecompress) { - zval**source, /* Source data to decompress */ - **zsmall; /* (Optional) user specified small */ - char *dest; /* Destination buffer, initially allocated */ - int error, /* Error container */ - iter = 1, /* Iteration count for the compression loop */ - size, /* Current size to realloc the dest buffer to */ - dest_len = PHP_BZ_DECOMPRESS_SIZE, /* Size of the destination length */ - small= 0, /* The actual small */ - argc = ZEND_NUM_ARGS(); /* Argument count */ - - if (argc 1 || argc 2 || zend_get_parameters_ex(argc, source, zsmall) == FAILURE) { - WRONG_PARAM_COUNT; + char *source, *dest; + int source_len, error; + long small = 0; + unsigned int size = 0; + bz_stream bzs; + + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, source, source_len, small)) { + RETURN_FALSE; } - convert_to_string_ex(source); - - /* optional small argument handling */ - if (argc 1) { - convert_to_long_ex(zsmall); - small = Z_LVAL_PP(zsmall); + bzs.bzalloc = NULL; + bzs.bzfree = NULL; + + if (BZ2_bzDecompressInit(bzs, 0, small) != BZ_OK) { + RETURN_FALSE; } - /* Depending on the size of the source buffer, either allocate - the length of the source buffer or the a default decompression - size */ - dest = emalloc(PHP_BZ_DECOMPRESS_SIZE Z_STRLEN_PP(source) ? PHP_BZ_DECOMPRESS_SIZE : Z_STRLEN_PP(source)); - - /* (de)Compression Loop */ - do { - /* Handle the (re)allocation of the buffer */ - size = dest_len * iter; - if (iter 1) { - dest = erealloc(dest, size); - } - ++iter; + bzs.next_in = source; + bzs.avail_in = source_len; - /* Perform the decompression */ - error = BZ2_bzBuffToBuffDecompress(dest, size, Z_STRVAL_PP(source), Z_STRLEN_PP(source), small, 0); - } while (error == BZ_OUTBUFF_FULL); - - if (error != BZ_OK) { - efree(dest); - RETURN_LONG(error); - } else { - /* we might have allocated a little to much, so erealloc the buffer -down to size, before returning it */ + /* in most cases bz2 offers at least 2:1 compression, so we use that as our base */ + bzs.avail_out = source_len * 2; + bzs.next_out = dest = emalloc(bzs.avail_out + 1); + + while ((error = BZ2_bzDecompress(bzs)) == BZ_OK bzs.avail_in 0) { + /* compression is better then 2:1, need to allocate more memory */ + bzs.avail_out = source_len; + size = (bzs.total_out_hi32 32) + bzs.total_out_lo32; + dest = erealloc(dest, size + bzs.avail_out + 1); + bzs.next_out = dest + size; + } + + if (error == BZ_STREAM_END || error == BZ_OK) { + size = (bzs.total_out_hi32 32) + bzs.total_out_lo32; dest = erealloc(dest, size + 1); - dest[size] = 0; - RETURN_STRINGL(dest, size, 0); + dest[size] = '\0'; + RETVAL_STRINGL(dest, size, 0); + } else { /* real error */ + efree(dest); + RETVAL_LONG(error); } + + BZ2_bzDecompressEnd(bzs); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe,
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c
tony2001Sat Mar 19 08:56:02 2005 EDT Modified files: /php-src/ext/bz2bz2.c Log: fix #32373 (segfault in bzopen('/wrong/path')) http://cvs.php.net/diff.php/php-src/ext/bz2/bz2.c?r1=1.8r2=1.9ty=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.8 php-src/ext/bz2/bz2.c:1.9 --- php-src/ext/bz2/bz2.c:1.8 Wed Feb 23 13:48:49 2005 +++ php-src/ext/bz2/bz2.c Sat Mar 19 08:56:00 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.8 2005/02/23 18:48:49 iliaa Exp $ */ +/* $Id: bz2.c,v 1.9 2005/03/19 13:56:00 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -196,7 +196,7 @@ /* remove the file created by php_stream_open_wrapper(), it is not needed since BZ2 functions * failed. */ - if (!bz_file mode[0] == 'w') { + if (opened_path !bz_file mode[0] == 'w') { VCWD_UNLINK(*opened_path); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c
iliaa Wed Feb 23 13:48:51 2005 EDT Modified files: /php-src/ext/bz2bz2.c Log: MFB_4_3: Fixed bug #29521 (compress.bzip2 returns error when used with http wrapper). http://cvs.php.net/diff.php/php-src/ext/bz2/bz2.c?r1=1.7r2=1.8ty=u Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.7 php-src/ext/bz2/bz2.c:1.8 --- php-src/ext/bz2/bz2.c:1.7 Tue Jul 20 01:26:33 2004 +++ php-src/ext/bz2/bz2.c Wed Feb 23 13:48:49 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.7 2004/07/20 05:26:33 pollita Exp $ */ +/* $Id: bz2.c,v 1.8 2005/02/23 18:48:49 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -185,7 +185,7 @@ if (bz_file == NULL) { /* that didn't work, so try and get something from the network/wrapper */ - stream = php_stream_open_wrapper(path, mode, options, opened_path); + stream = php_stream_open_wrapper(path, mode, options | STREAM_WILL_CAST, opened_path); if (stream) { int fd; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c /ext/curl streams.c /ext/standard file.c ftp_fopen_wrapper.c http_fopen_wrapper.c php_fopen_wrapper.c /ext/zlib zlib_fopen_wrapper.c /main php_streams.h /main/streams plain_wrapper.c userspace.c
pollita Fri Dec 12 18:05:20 2003 EDT Modified files: /php-src/ext/standard file.c ftp_fopen_wrapper.c http_fopen_wrapper.c php_fopen_wrapper.c /php-src/main php_streams.h /php-src/main/streams plain_wrapper.c userspace.c /php-src/ext/zlib zlib_fopen_wrapper.c /php-src/ext/bz2bz2.c /php-src/ext/curl streams.c Log: Route rename() via wrapper ops. Move current rename() code to main/streams/plain_wrapper.c Implement ftp/rename() Implement userstreams/rename() Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.368 php-src/ext/standard/file.c:1.369 --- php-src/ext/standard/file.c:1.368 Wed Dec 10 01:08:39 2003 +++ php-src/ext/standard/file.c Fri Dec 12 18:05:15 2003 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: file.c,v 1.368 2003/12/10 06:08:39 moriyoshi Exp $ */ +/* $Id: file.c,v 1.369 2003/12/12 23:05:15 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1437,48 +1437,40 @@ } /* }}} */ -/* {{{ proto bool rename(string old_name, string new_name) +/* {{{ proto bool rename(string old_name, string new_name[, resource context]) Rename a file */ PHP_FUNCTION(rename) { - zval **old_arg, **new_arg; char *old_name, *new_name; - int ret; + int old_name_len, new_name_len; + zval *zcontext = NULL; + php_stream_wrapper *wrapper; + php_stream_context *context; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, old_arg, new_arg) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|r, old_name, old_name_len, new_name, new_name_len, zcontext) == FAILURE) { + RETURN_FALSE; } - convert_to_string_ex(old_arg); - convert_to_string_ex(new_arg); - - old_name = Z_STRVAL_PP(old_arg); - new_name = Z_STRVAL_PP(new_arg); + wrapper = php_stream_locate_url_wrapper(old_name, NULL, 0 TSRMLS_CC); - if (PG(safe_mode) (!php_checkuid(old_name, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { + if (!wrapper || !wrapper-wops) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to locate stream wrapper.); RETURN_FALSE; } - if (php_check_open_basedir(old_name TSRMLS_CC)) { + if (!wrapper-wops-rename) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, %s wrapper does not support renaming., wrapper-wops-label ? wrapper-wops-label : Source); RETURN_FALSE; } - ret = VCWD_RENAME(old_name, new_name); - - if (ret == -1) { -#ifdef EXDEV - if (errno == EXDEV) { - if (php_copy_file(old_name, new_name TSRMLS_CC) == SUCCESS) { - VCWD_UNLINK(old_name); - RETURN_TRUE; - } - } -#endif - php_error_docref2(NULL TSRMLS_CC, old_name, new_name, E_WARNING, %s, strerror(errno)); + if (wrapper != php_stream_locate_url_wrapper(new_name, NULL, 0 TSRMLS_CC)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot rename a file across wrapper types.); RETURN_FALSE; } - RETURN_TRUE; + context = php_stream_context_from_zval(zcontext, 0); + + RETURN_BOOL(wrapper-wops-rename(wrapper, old_name, new_name, 0, context TSRMLS_CC)); } /* }}} */ Index: php-src/ext/standard/ftp_fopen_wrapper.c diff -u php-src/ext/standard/ftp_fopen_wrapper.c:1.68 php-src/ext/standard/ftp_fopen_wrapper.c:1.69 --- php-src/ext/standard/ftp_fopen_wrapper.c:1.68 Wed Dec 10 16:23:34 2003 +++ php-src/ext/standard/ftp_fopen_wrapper.cFri Dec 12 18:05:15 2003 @@ -18,7 +18,7 @@ | Sara Golemon [EMAIL PROTECTED] | +--+ */ -/* $Id: ftp_fopen_wrapper.c,v 1.68 2003/12/10 21:23:34 iliaa Exp $ */ +/* $Id: ftp_fopen_wrapper.c,v 1.69 2003/12/12 23:05:15 pollita Exp $ */ #include php.h #include php_globals.h @@ -842,6 +842,89 @@ } /* }}} */ +/* {{{ php_stream_ftp_rename + */ +static int php_stream_ftp_rename(php_stream_wrapper *wrapper, char *url_from, char *url_to, int options, php_stream_context *context TSRMLS_DC) +{ + php_stream *stream = NULL; + php_url *resource_from = NULL, *resource_to = NULL; + int result; + char tmp_line[512]; + + resource_from = php_url_parse(url_from); + resource_to = php_url_parse(url_to); + /* Must be same scheme (ftp/ftp or ftps/ftps), same host, and same port + (or a 21/0 0/21 combination which is also same) + Also require paths to/from */ + if (!resource_from || + !resource_to || + !resource_from-scheme || +
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c php_bz2.h /ext/mono php_mono.c php_mono.h /ext/simplexml php_simplexml.h simplexml.c /main php_realpath.c
sniper Tue Dec 9 11:29:56 2003 EDT Modified files: /php-src/main php_realpath.c /php-src/ext/simplexml php_simplexml.h simplexml.c /php-src/ext/mono php_mono.c php_mono.h /php-src/ext/bz2bz2.c php_bz2.h Log: - Update header + added missing Id tags. Index: php-src/main/php_realpath.c diff -u php-src/main/php_realpath.c:1.13 php-src/main/php_realpath.c:1.14 --- php-src/main/php_realpath.c:1.13Sun Aug 27 14:01:17 2000 +++ php-src/main/php_realpath.c Tue Dec 9 11:29:50 2003 @@ -1,20 +1,22 @@ /* - +--+ - | PHP version 4.0 | - +--+ - | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | - +--+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is| - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | [EMAIL PROTECTED] so we can mail you a copy immediately. | - +--+ - | Author: Sander Steffann ([EMAIL PROTECTED]) | - +--+ - */ + +--+ + | PHP Version 5| + +--+ + | Copyright (c) 1997-2003 The PHP Group| + +--+ + | This source file is subject to version 3.0 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is| + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_0.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | [EMAIL PROTECTED] so we can mail you a copy immediately. | + +--+ + | Author: Sander Steffann ([EMAIL PROTECTED]) | + +--+ +*/ + +/* $Id: php_realpath.c,v 1.14 2003/12/09 16:29:50 sniper Exp $ */ #include php.h Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.9 php-src/ext/simplexml/php_simplexml.h:1.10 --- php-src/ext/simplexml/php_simplexml.h:1.9 Sun Nov 23 11:20:57 2003 +++ php-src/ext/simplexml/php_simplexml.h Tue Dec 9 11:29:51 2003 @@ -1,13 +1,13 @@ /* +--+ - | PHP Version 4| + | PHP Version 5| +--+ | Copyright (c) 1997-2003 The PHP Group| +--+ - | This source file is subject to version 2.02 of the PHP license, | + | This source file is subject to version 3.0 of the PHP license, | | that is bundled with this package in the file LICENSE, and is| - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_0.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_simplexml.h,v 1.9 2003/11/23 16:20:57 helly Exp $ */ +/* $Id: php_simplexml.h,v 1.10 2003/12/09 16:29:51 sniper Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.90 php-src/ext/simplexml/simplexml.c:1.91 --- php-src/ext/simplexml/simplexml.c:1.90 Sun Dec 7 06:32:40 2003 +++
[PHP-CVS] cvs: php-src /ext/bz2 bz2.c
iliaa Mon Sep 15 19:49:33 2003 EDT Modified files: /php-src/ext/bz2bz2.c Log: Fixed bug #25106 (Added more stringent checks on bzopen() mode). In some cases bz2 may fail to open the file, but stream wrappers will still create an empty file, remove this file. Change virtual_filepath to virtual_filepath_ex, which allows BZ2_bzfopen() to work without having to resort to stream wrappers. Index: php-src/ext/bz2/bz2.c diff -u php-src/ext/bz2/bz2.c:1.1 php-src/ext/bz2/bz2.c:1.2 --- php-src/ext/bz2/bz2.c:1.1 Sat May 17 10:27:07 2003 +++ php-src/ext/bz2/bz2.c Mon Sep 15 19:49:32 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: bz2.c,v 1.1 2003/05/17 14:27:07 sterling Exp $ */ +/* $Id: bz2.c,v 1.2 2003/09/15 23:49:32 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -165,9 +165,12 @@ if (strncasecmp(compress.bzip2://, path, 17) == 0) { path += 17; } + if (mode[0] != 'w' mode[0] != 'r' mode[1] != '\0') { + return NULL; + } #ifdef VIRTUAL_DIR - virtual_filepath(path, path_copy TSRMLS_CC); + virtual_filepath_ex(path, path_copy, NULL TSRMLS_CC); #else path_copy = path; #endif @@ -190,6 +193,12 @@ bz_file = BZ2_bzdopen(fd, mode); } } + /* remove the file created by php_stream_open_wrapper(), it is not needed since BZ2 functions +* failed. +*/ + if (!bz_file mode[0] == 'w') { + VCWD_UNLINK(*opened_path); + } } if (bz_file) { @@ -303,7 +312,12 @@ WRONG_PARAM_COUNT; } convert_to_string_ex(mode); - + + if (Z_STRVAL_PP(mode)[0] != 'r' Z_STRVAL_PP(mode)[0] != 'w' Z_STRVAL_PP(mode)[1] != '\0') { + 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; + } + /* 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); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php