[PHP-CVS] cvs: php-src(PHP_5_2) /ext/zip php_zip.c php_zip.h
pajoye Thu Feb 5 19:53:22 2009 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c php_zip.h Log: - Fixed a crash on extract in zip when files or directories entry names contain a relative path. (affects only 5.2 as it is a limitation in 5.2's virtual_file_ex) http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.48r2=1.1.2.49diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.48 php-src/ext/zip/php_zip.c:1.1.2.49 --- php-src/ext/zip/php_zip.c:1.1.2.48 Fri Jan 2 00:12:29 2009 +++ php-src/ext/zip/php_zip.c Thu Feb 5 19:53:22 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.48 2009/01/02 00:12:29 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.49 2009/02/05 19:53:22 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -31,6 +31,10 @@ #include lib/zip.h #include lib/zipint.h +#ifdef PHP_WIN32 +#include tsrm_virtual_cwd.h +#endif + /* zip_open is a macro for renaming libzip zipopen, so we need to use PHP_NAMED_FUNCTION */ static PHP_NAMED_FUNCTION(zif_zip_open); static PHP_NAMED_FUNCTION(zif_zip_read); @@ -86,6 +90,284 @@ # define add_ascii_assoc_long add_assoc_long #endif +static int php_zip_realpath_r(char *path, int start, int len, int *ll, time_t *t, int use_realpath, int is_dir, int *link_is_dir TSRMLS_DC) /* {{{ */ +{ + int i, j; + char *tmp; + + while (1) { + if (len = start) { + return start; + } + + i = len; + while (i start !IS_SLASH(path[i-1])) { + i--; + } + + if (i == len || + (i == len - 1 path[i] == '.')) { + /* remove double slashes and '.' */ + len = i - 1; + is_dir = 1; + continue; + } else if (i == len - 2 path[i] == '.' path[i+1] == '.') { + /* remove '..' and previous directory */ + if (i - 1 = start) { + return start ? start : len; + } + j = php_zip_realpath_r(path, start, i-1, ll, t, use_realpath, 1, NULL TSRMLS_CC); + if (j start) { + j--; + while (j start !IS_SLASH(path[j])) { + j--; + } + if (!start) { + /* leading '..' must not be removed in case of relative path */ + if (j == 0 path[0] == '.' path[1] == '.' + IS_SLASH(path[2])) { + path[3] = '.'; + path[4] = '.'; + path[5] = DEFAULT_SLASH; + j = 5; + } else if (j 0 + path[j+1] == '.' path[j+2] == '.' + IS_SLASH(path[j+3])) { + j += 4; + path[j++] = '.'; + path[j++] = '.'; + path[j] = DEFAULT_SLASH; + } + } + } else if (!start !j) { + /* leading '..' must not be removed in case of relative path */ + path[0] = '.'; + path[1] = '.'; + path[2] = DEFAULT_SLASH; + j = 2; + } + return j; + } + + path[len] = 0; + +#ifdef PHP_WIN32 + tmp = tsrm_do_alloca(len+1); + memcpy(tmp, path, len+1); +#elif defined(NETWARE) + + tmp = tsrm_do_alloca(len+1); + memcpy(tmp, path, len+1); +#else + tmp = tsrm_do_alloca(len+1); + memcpy(tmp, path, len+1); + + { +#endif + if (i - 1 = start) { + j = start; + } else { + /* some leading directories may be unaccessable */ + j = php_zip_realpath_r(path, start, i-1, ll, t, use_realpath, 1, NULL TSRMLS_CC); + if (j start) { + path[j++] = DEFAULT_SLASH; + } + } +#ifdef
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/zip php_zip.c
pajoye Fri Jan 2 00:12:29 2009 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - MFH: fix filename property read http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.47r2=1.1.2.48diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.47 php-src/ext/zip/php_zip.c:1.1.2.48 --- php-src/ext/zip/php_zip.c:1.1.2.47 Wed Dec 31 11:17:47 2008 +++ php-src/ext/zip/php_zip.c Fri Jan 2 00:12:29 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.47 2008/12/31 11:17:47 sebastian Exp $ */ +/* $Id: php_zip.c,v 1.1.2.48 2009/01/02 00:12:29 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -534,7 +534,7 @@ switch (hnd-type) { case IS_STRING: if (retchar) { - ZVAL_STRINGL(*retval, (char *) retchar, len, 1); + ZVAL_STRING(*retval, (char *) retchar, 1); } else { ZVAL_EMPTY_STRING(*retval); } @@ -2273,7 +2273,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.47 2008/12/31 11:17:47 sebastian Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.48 2009/01/02 00:12:29 pajoye Exp $); php_info_print_table_row(2, Zip version, PHP_ZIP_VERSION_STRING); php_info_print_table_row(2, Libzip version, 0.9.0); -- 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/zip php_zip.c
felipe Wed Nov 12 17:50:37 2008 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - MFH: Removed unused variables http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.45r2=1.1.2.46diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.45 php-src/ext/zip/php_zip.c:1.1.2.46 --- php-src/ext/zip/php_zip.c:1.1.2.45 Wed Nov 12 11:59:26 2008 +++ php-src/ext/zip/php_zip.c Wed Nov 12 17:50:37 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.45 2008/11/12 11:59:26 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.46 2008/11/12 17:50:37 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -90,9 +90,6 @@ static char * php_zip_make_relative_path(char *path, int path_len) /* {{{ */ { char *path_begin = path; - int prev_is_slash = 0; - char *e = path + path_len - 1; - size_t pos = path_len - 1; size_t i; if (IS_SLASH(path[0])) { @@ -2276,7 +2273,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.45 2008/11/12 11:59:26 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.46 2008/11/12 17:50:37 felipe Exp $); php_info_print_table_row(2, Zip version, PHP_ZIP_VERSION_STRING); php_info_print_table_row(2, Libzip version, 0.9.0); -- 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/zip php_zip.c php_zip.h /ext/zip/tests bug14962.phpt bug38943.inc bug38943.phpt bug38943_2.phpt bug7658.phpt oo_delete.phpt
pajoye Wed Nov 12 11:59:26 2008 UTC Added files: (Branch: PHP_5_2) /php-src/ext/zip/tests bug14962.phpt bug38943.inc bug38943_2.phpt Modified files: /php-src/ext/zipphp_zip.c php_zip.h /php-src/ext/zip/tests bug38943.phpt bug7658.phpt oo_delete.phpt Log: - MFH: - #14962, makes extractTo 2nd argument really optional - replace ZEND_ENGINE_2_1 by PHP_ZIP_USE_OO - sync tests http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.44r2=1.1.2.45diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.44 php-src/ext/zip/php_zip.c:1.1.2.45 --- php-src/ext/zip/php_zip.c:1.1.2.44 Thu Oct 23 16:13:50 2008 +++ php-src/ext/zip/php_zip.c Wed Nov 12 11:59:26 2008 @@ -12,11 +12,11 @@ | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +--+ - | Author: Piere-Alain Joye [EMAIL PROTECTED] | + | Author: Piere-Alain Joye [EMAIL PROTECTED]| +--+ */ -/* $Id: php_zip.c,v 1.1.2.44 2008/10/23 16:13:50 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.45 2008/11/12 11:59:26 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -473,7 +473,7 @@ /* }}} */ /* {{{ ZE2 OO definitions */ -#ifdef ZEND_ENGINE_2_1 +#ifdef PHP_ZIP_USE_OO static zend_class_entry *zip_class_entry; static zend_object_handlers zip_object_handlers; @@ -493,7 +493,7 @@ #endif /* }}} */ -#ifdef ZEND_ENGINE_2_1 +#ifdef PHP_ZIP_USE_OO static void php_zip_register_prop_handler(HashTable *prop_handler, char *name, zip_read_int_t read_int_func, zip_read_const_char_t read_char_func, zip_read_const_char_from_ze_t read_char_from_obj_func, int rettype TSRMLS_DC) /* {{{ */ { zip_prop_handler hnd; @@ -1137,7 +1137,7 @@ } /* }}} */ -#ifdef ZEND_ENGINE_2_1 +#ifdef PHP_ZIP_USE_OO /* {{{ proto mixed ZipArchive::open(string source [, int flags]) Create new zip using source uri for output, return TRUE on success or the error code */ static ZIPARCHIVE_METHOD(open) @@ -1975,7 +1975,7 @@ } ZIP_FROM_OBJECT(intern, this); - if (zval_files) { + if (zval_files (Z_TYPE_P(zval_files) != IS_NULL)) { switch (Z_TYPE_P(zval_files)) { case IS_STRING: if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files) TSRMLS_CC)) { @@ -2276,7 +2276,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.44 2008/10/23 16:13:50 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.45 2008/11/12 11:59:26 pajoye Exp $); php_info_print_table_row(2, Zip version, PHP_ZIP_VERSION_STRING); php_info_print_table_row(2, Libzip version, 0.9.0); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.h?r1=1.10.2.6r2=1.10.2.7diff_format=u Index: php-src/ext/zip/php_zip.h diff -u php-src/ext/zip/php_zip.h:1.10.2.6 php-src/ext/zip/php_zip.h:1.10.2.7 --- php-src/ext/zip/php_zip.h:1.10.2.6 Thu Oct 23 16:13:50 2008 +++ php-src/ext/zip/php_zip.h Wed Nov 12 11:59:26 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.h,v 1.10.2.6 2008/10/23 16:13:50 pajoye Exp $ */ +/* $Id: php_zip.h,v 1.10.2.7 2008/11/12 11:59:26 pajoye Exp $ */ #ifndef PHP_ZIP_H #define PHP_ZIP_H @@ -32,10 +32,8 @@ #define PHP_ZIP_VERSION_STRING 1.8.11 -#ifndef ZEND_ENGINE_2_1 -# if (PHP_MAJOR_VERSION == 5 PHP_MINOR_VERSION 0) || PHP_MAJOR_VERSION == 6 -# define ZEND_ENGINE_2_1 -# endif +#if ((PHP_MAJOR_VERSION = 5 PHP_MINOR_VERSION = 2) || PHP_MAJOR_VERSION = 6) +# define PHP_ZIP_USE_OO 1 #endif #ifndef Z_SET_REFCOUNT_P @@ -68,7 +66,7 @@ struct zip_stat sb; } zip_read_rsrc; -#ifdef ZEND_ENGINE_2_1 +#ifdef PHP_ZIP_USE_OO #define ZIPARCHIVE_ME(name, arg_info, flags) ZEND_FENTRY(name, c_ziparchive_ ##name, arg_info, flags) #define ZIPARCHIVE_METHOD(name)ZEND_NAMED_FUNCTION(c_ziparchive_##name) http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug38943.phpt?r1=1.1.2.2r2=1.1.2.3diff_format=u Index: php-src/ext/zip/tests/bug38943.phpt diff -u php-src/ext/zip/tests/bug38943.phpt:1.1.2.2 php-src/ext/zip/tests/bug38943.phpt:1.1.2.3 --- php-src/ext/zip/tests/bug38943.phpt:1.1.2.2 Mon Oct 9 16:02:34 2006 +++ php-src/ext/zip/tests/bug38943.phpt Wed Nov 12 11:59:26 2008 @@ -1,26 +1,14 @@ --TEST-- -#38943, properties in extended class cannot be set +#38943, properties in extended class cannot be set ( 5.3) --SKIPIF-- ?php -/* $Id: bug38943.phpt,v 1.1.2.2 2006/10/09 16:02:34
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/zip php_zip.c
bjori Sat Dec 15 12:52:11 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: Fix protos http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.38r2=1.1.2.39diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.38 php-src/ext/zip/php_zip.c:1.1.2.39 --- php-src/ext/zip/php_zip.c:1.1.2.38 Mon Aug 6 22:02:32 2007 +++ php-src/ext/zip/php_zip.c Sat Dec 15 12:52:11 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.38 2007/08/06 22:02:32 bjori Exp $ */ +/* $Id: php_zip.c,v 1.1.2.39 2007/12/15 12:52:11 bjori Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -939,7 +939,7 @@ } /* }}} */ -/* {{{ proto mixed open(string source [, int flags]) +/* {{{ proto mixed ZipArchive::open(string source [, int flags]) Create new zip using source uri for output, return TRUE on success or the error code */ static ZIPARCHIVE_METHOD(open) { @@ -997,7 +997,7 @@ } /* }}} */ -/* {{{ proto bool close() +/* {{{ proto bool ZipArchive::close() close the zip archive */ static ZIPARCHIVE_METHOD(close) { @@ -1026,7 +1026,7 @@ } /* }}} */ -/* {{{ proto bool createEmptyDir(string dirname) U +/* {{{ proto bool ZipArchive::createEmptyDir(string dirname) Returns the index of the entry named filename in the archive */ static ZIPARCHIVE_METHOD(addEmptyDir) { @@ -1085,7 +1085,7 @@ } /* }}} */ -/* {{{ proto bool addFile(string filepath[, string entryname[, int start [, int length]]]) +/* {{{ proto bool ZipArchive::addFile(string filepath[, string entryname[, int start [, int length]]]) Add a file in a Zip archive using its path and the name to use. */ static ZIPARCHIVE_METHOD(addFile) { @@ -1157,7 +1157,7 @@ } /* }}} */ -/* {{{ proto bool addFromString(string name, string content) +/* {{{ proto bool ZipArchive::addFromString(string name, string content) Add a file using content and the entry name */ static ZIPARCHIVE_METHOD(addFromString) { @@ -1222,7 +1222,7 @@ } /* }}} */ -/* {{{ proto array statName(string filename[, int flags]) +/* {{{ proto array ZipArchive::statName(string filename[, int flags]) Returns the information about a the zip entry filename */ static ZIPARCHIVE_METHOD(statName) { @@ -1250,7 +1250,7 @@ } /* }}} */ -/* {{{ proto resource statIndex(int index[, int flags]) +/* {{{ proto resource ZipArchive::statIndex(int index[, int flags]) Returns the zip entry informations using its index */ static ZIPARCHIVE_METHOD(statIndex) { @@ -1278,7 +1278,7 @@ } /* }}} */ -/* {{{ proto int locateName(string filename[, int flags]) +/* {{{ proto int ZipArchive::locateName(string filename[, int flags]) Returns the index of the entry named filename in the archive */ static ZIPARCHIVE_METHOD(locateName) { @@ -1318,7 +1318,7 @@ } /* }}} */ -/* {{{ proto string getNameIndex(int index [, int flags]) +/* {{{ proto string ZipArchive::getNameIndex(int index [, int flags]) Returns the name of the file at position index */ static ZIPARCHIVE_METHOD(getNameIndex) { @@ -1348,7 +1348,7 @@ } /* }}} */ -/* {{{ proto bool setArchiveComment(string name, string comment) +/* {{{ proto bool ZipArchive::setArchiveComment(string name, string comment) Set or remove (NULL/'') the comment of the archive */ static ZIPARCHIVE_METHOD(setArchiveComment) { @@ -1374,7 +1374,7 @@ } /* }}} */ -/* {{{ proto string getArchiveComment() +/* {{{ proto string ZipArchive::getArchiveComment() Returns the comment of an entry using its index */ static ZIPARCHIVE_METHOD(getArchiveComment) { @@ -1399,7 +1399,7 @@ } /* }}} */ -/* {{{ proto bool setCommentName(string name, string comment) +/* {{{ proto bool ZipArchive::setCommentName(string name, string comment) Set or remove (NULL/'') the comment of an entry using its Name */ static ZIPARCHIVE_METHOD(setCommentName) { @@ -1432,7 +1432,7 @@ } /* }}} */ -/* {{{ proto bool setCommentIndex(int index, string comment) +/* {{{ proto bool ZipArchive::setCommentIndex(int index, string comment) Set or remove (NULL/'') the comment of an entry using its index */ static ZIPARCHIVE_METHOD(setCommentIndex) { @@ -1459,7 +1459,7 @@ } /* }}} */ -/* {{{ proto string getCommentName(string name) +/* {{{ proto string ZipArchive::getCommentName(string name) Returns the comment of an entry using its name */ static ZIPARCHIVE_METHOD(getCommentName) { @@ -1496,7 +1496,7 @@ } /* }}} */ -/* {{{ proto string getCommentIndex(int index) +/* {{{ proto string ZipArchive::getCommentIndex(int index) Returns the comment of an entry using its index */ static ZIPARCHIVE_METHOD(getCommentIndex) { @@ -1524,7 +1524,7 @@ } /* }}} */ -/* {{{ proto bool deleteIndex(int index) +/* {{{ proto bool ZipArchive::deleteIndex(int index) Delete a file using its index */ static ZIPARCHIVE_METHOD(deleteIndex) { @@ -1554,7 +1554,7 @@ } /* }}} */ -/* {{{ proto bool deleteName(string name)
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/zip php_zip.c /ext/zip/tests oo_properties.phpt
bjori Mon Aug 6 22:02:32 2007 UTC Added files: (Branch: PHP_5_2) /php-src/ext/zip/tests oo_properties.phpt Modified files: /php-src/ext/zipphp_zip.c Log: MFH: - Fix isset/empty($ZipArchive-property) MFH: - Add test http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.37r2=1.1.2.38diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.37 php-src/ext/zip/php_zip.c:1.1.2.38 --- php-src/ext/zip/php_zip.c:1.1.2.37 Mon Jun 4 06:38:22 2007 +++ php-src/ext/zip/php_zip.c Mon Aug 6 22:02:32 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.37 2007/06/04 06:38:22 tony2001 Exp $ */ +/* $Id: php_zip.c,v 1.1.2.38 2007/08/06 22:02:32 bjori Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -449,6 +449,55 @@ } /* }}} */ +static int php_zip_has_property(zval *object, zval *member, int type TSRMLS_DC) /* {{{ */ +{ + ze_zip_object *obj; + zval tmp_member; + zip_prop_handler *hnd; + zend_object_handlers *std_hnd; + int ret, retval = 0; + + if (member-type != IS_STRING) { + tmp_member = *member; + zval_copy_ctor(tmp_member); + convert_to_string(tmp_member); + member = tmp_member; + } + + ret = FAILURE; + obj = (ze_zip_object *)zend_objects_get_address(object TSRMLS_CC); + + if (obj-prop_handler != NULL) { + ret = zend_hash_find(obj-prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) hnd); + } + + if (ret == SUCCESS) { + zval *tmp; + + if (type == 2) { + retval = 1; + } else if (php_zip_property_reader(obj, hnd, tmp, 1 TSRMLS_CC) == SUCCESS) { + tmp-refcount = 1; + tmp-is_ref = 0; + if (type == 1) { + retval = zend_is_true(tmp); + } else if (type == 0) { + retval = (Z_TYPE_P(tmp) != IS_NULL); + } + zval_ptr_dtor(tmp); + } + } else { + std_hnd = zend_get_std_object_handlers(); + retval = std_hnd-has_property(object, member, type TSRMLS_CC); + } + + if (member == tmp_member) { + zval_dtor(member); + } + return retval; +} +/* }}} */ + static HashTable *php_zip_get_properties(zval *object TSRMLS_DC)/* {{{ */ { ze_zip_object *obj; @@ -1965,6 +2014,7 @@ zip_object_handlers.get_properties = php_zip_get_properties; zip_object_handlers.read_property = php_zip_read_property; + zip_object_handlers.has_property= php_zip_has_property; INIT_CLASS_ENTRY(ce, ZipArchive, zip_class_functions); ce.create_object = php_zip_object_new; @@ -2051,7 +2101,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.37 2007/06/04 06:38:22 tony2001 Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.38 2007/08/06 22:02:32 bjori Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/oo_properties.phpt?view=markuprev=1.1 Index: php-src/ext/zip/tests/oo_properties.phpt +++ php-src/ext/zip/tests/oo_properties.phpt --TEST-- ziparchive::properties isset()/empty() checks --SKIPIF-- ?php /* $Id: oo_properties.phpt,v 1.1 2007/08/06 21:59:11 bjori Exp $ */ if(!extension_loaded('zip')) die('skip'); ? --FILE-- ?php $dirname = dirname(__FILE__) . '/'; $file = $dirname . '__property_test.zip'; copy($dirname . 'test_with_comment.zip', $file); $zip = new ZipArchive; if (!$zip-open($file)) { exit('failed'); } printf(zip-status (%d):\n\tempty(): %d\n\tisset(): %d\n, $zip-status, empty($zip-status), isset($zip-status)); printf(zip-numFiles (%d):\n\tempty(): %d\n\tisset(): %d\n, $zip-numFiles, empty($zip-numFiles), isset($zip-numFiles)); printf(zip-bogus (%d):\n\tempty(): %d\n\tisset(): %d\n, $zip-bogus, empty($zip-bogus), isset($zip-bogus)); $zip-addEmptyDir('emptydir'); printf(zip-status (%d):\n\tempty(): %d\n\tisset(): %d\n, $zip-status, empty($zip-status), isset($zip-status)); printf(zip-numFiles (%d):\n\tempty(): %d\n\tisset(): %d\n, $zip-numFiles, empty($zip-numFiles), isset($zip-numFiles)); printf(zip-filename (%d):\n\tempty(): %d\n\tisset(): %d\n, strlen($zip-filename), empty($zip-filename), isset($zip-filename)); printf(zip-comment (%d):\n\tempty(): %d\n\tisset(): %d\n, strlen($zip-comment), empty($zip-comment), isset($zip-comment)); @unlink($file); ? --EXPECTF-- zip-status (0): empty(): 1
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/zip php_zip.c
tony2001Mon Jun 4 06:38:22 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: fix ws http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.36r2=1.1.2.37diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.36 php-src/ext/zip/php_zip.c:1.1.2.37 --- php-src/ext/zip/php_zip.c:1.1.2.36 Sun Jun 3 21:34:21 2007 +++ php-src/ext/zip/php_zip.c Mon Jun 4 06:38:22 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.36 2007/06/03 21:34:21 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.37 2007/06/04 06:38:22 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1004,12 +1004,12 @@ RETURN_FALSE; } -if (dirname[dirname_len-1] != '/') { + if (dirname[dirname_len-1] != '/') { s=(char *)emalloc(dirname_len+2); strcpy(s, dirname); s[dirname_len] = '/'; s[dirname_len+1] = '\0'; -} else { + } else { s = dirname; } @@ -2051,7 +2051,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.36 2007/06/03 21:34:21 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.37 2007/06/04 06:38:22 tony2001 Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
pajoye Sun Jun 3 21:34:21 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - fix logic (goto is a gift, I should use it :) http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.35r2=1.1.2.36diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.35 php-src/ext/zip/php_zip.c:1.1.2.36 --- php-src/ext/zip/php_zip.c:1.1.2.35 Sun Jun 3 21:21:57 2007 +++ php-src/ext/zip/php_zip.c Sun Jun 3 21:34:21 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.35 2007/06/03 21:21:57 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.36 2007/06/03 21:34:21 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1025,8 +1025,9 @@ if (zip_add_dir(intern, (const char *)s) == -1) { RETVAL_FALSE; + } else { + RETVAL_TRUE; } - RETVAL_TRUE; } if (s != dirname) { @@ -2050,7 +2051,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.35 2007/06/03 21:21:57 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.36 2007/06/03 21:34:21 pajoye Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
iliaa Sat May 19 19:29:37 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: CS fixes Fixed a possible crash in the event directory cannot be created, due to a double free. http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.31r2=1.1.2.32diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.31 php-src/ext/zip/php_zip.c:1.1.2.32 --- php-src/ext/zip/php_zip.c:1.1.2.31 Wed Mar 14 15:02:20 2007 +++ php-src/ext/zip/php_zip.c Sat May 19 19:29:37 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.31 2007/03/14 15:02:20 iliaa Exp $ */ +/* $Id: php_zip.c,v 1.1.2.32 2007/05/19 19:29:37 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1699,7 +1699,6 @@ zval **zval_file = NULL; php_stream_statbuf ssb; char *pathto; - char *file; int pathto_len; int ret, i; @@ -1713,24 +1712,22 @@ return; } - if (pathto_len1) { + if (pathto_len 1) { RETURN_FALSE; } -if (php_stream_stat_path(pathto, ssb) 0) { -ret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL); -if (!ret) { -efree(pathto); -RETURN_FALSE; -} -} + if (php_stream_stat_path(pathto, ssb) 0) { + ret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL); + if (!ret) { + RETURN_FALSE; + } + } ZIP_FROM_OBJECT(intern, this); if (zval_files) { switch (Z_TYPE_P(zval_files)) { case IS_STRING: - file = Z_STRVAL_P(zval_files); - if (!php_zip_extract_file(intern, pathto, file, Z_STRLEN_P(zval_files) TSRMLS_CC)) { + if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files) TSRMLS_CC)) { RETURN_FALSE; } break; @@ -1745,8 +1742,7 @@ case IS_LONG: break; case IS_STRING: - file = Z_STRVAL_PP(zval_file); - if (!php_zip_extract_file(intern, pathto, file, Z_STRLEN_PP(zval_file) TSRMLS_CC)) { + if (!php_zip_extract_file(intern, pathto, Z_STRVAL_PP(zval_file), Z_STRLEN_PP(zval_file) TSRMLS_CC)) { RETURN_FALSE; } break; @@ -1760,22 +1756,21 @@ break; } } else { -/* Extract all files */ -int filecount = zip_get_num_files(intern); + /* Extract all files */ + int filecount = zip_get_num_files(intern); -if (filecount == -1) { -php_error_docref(NULL TSRMLS_CC, E_WARNING, Illegal archive); -RETURN_FALSE; -} - -for (i = 0; i filecount; i++) { -file = (char*)zip_get_name(intern, i, ZIP_FL_UNCHANGED); -if (!php_zip_extract_file(intern, pathto, file, strlen(file) TSRMLS_CC)) { -RETURN_FALSE; -} -} -} + if (filecount == -1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Illegal archive); + RETURN_FALSE; + } + for (i = 0; i filecount; i++) { + char *file = (char*)zip_get_name(intern, i, ZIP_FL_UNCHANGED); + if (!php_zip_extract_file(intern, pathto, file, strlen(file) TSRMLS_CC)) { + RETURN_FALSE; + } + } + } RETURN_TRUE; } /* }}} */ @@ -2027,7 +2022,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.31 2007/03/14 15:02:20 iliaa Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.32 2007/05/19 19:29:37 iliaa Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
pajoye Sat May 19 22:25:11 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - use the same checks for zip_stat http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.32r2=1.1.2.33diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.32 php-src/ext/zip/php_zip.c:1.1.2.33 --- php-src/ext/zip/php_zip.c:1.1.2.32 Sat May 19 19:29:37 2007 +++ php-src/ext/zip/php_zip.c Sat May 19 22:25:11 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.32 2007/05/19 19:29:37 iliaa Exp $ */ +/* $Id: php_zip.c,v 1.1.2.33 2007/05/19 22:25:11 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -62,7 +62,7 @@ php_error_docref(NULL TSRMLS_CC, E_NOTICE, Empty string as entry name); \ RETURN_FALSE; \ } \ - if (zip_stat(za, path, flags, sb)) { \ + if (zip_stat(za, path, flags, sb) != 0) { \ RETURN_FALSE; \ } /* }}} */ @@ -103,7 +103,7 @@ size_t file_basename_len; int is_dir_only = 0; - if (file_len = MAXPATHLEN || zip_stat(za, file, 0, sb)) { + if (file_len = MAXPATHLEN || zip_stat(za, file, 0, sb) != 0) { return 0; } @@ -1879,7 +1879,7 @@ return; } - if (zip_stat(intern, filename, 0, sb)) { + if (zip_stat(intern, filename, 0, sb) != 0) { RETURN_FALSE; } @@ -2022,7 +2022,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.32 2007/05/19 19:29:37 iliaa Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.33 2007/05/19 22:25:11 pajoye Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
pajoye Wed Mar 14 12:06:20 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - MFH: openbasedir and safemode check in ::open() http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.29r2=1.1.2.30diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.29 php-src/ext/zip/php_zip.c:1.1.2.30 --- php-src/ext/zip/php_zip.c:1.1.2.29 Wed Mar 14 11:32:25 2007 +++ php-src/ext/zip/php_zip.c Wed Mar 14 12:06:20 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.29 2007/03/14 11:32:25 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.30 2007/03/14 12:06:20 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -917,6 +917,10 @@ RETURN_FALSE; } + if (OPENBASEDIR_CHECKPATH(filename)) { + RETURN_FALSE; + } + if (!expand_filepath(filename, resolved_path TSRMLS_CC)) { RETURN_FALSE; } @@ -2022,7 +2026,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.29 2007/03/14 11:32:25 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.30 2007/03/14 12:06:20 pajoye Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
iliaa Wed Mar 14 15:02:20 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: Fixed a possible memory leak on open_basedir validation http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.30r2=1.1.2.31diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.30 php-src/ext/zip/php_zip.c:1.1.2.31 --- php-src/ext/zip/php_zip.c:1.1.2.30 Wed Mar 14 12:06:20 2007 +++ php-src/ext/zip/php_zip.c Wed Mar 14 15:02:20 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.30 2007/03/14 12:06:20 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.31 2007/03/14 15:02:20 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -160,6 +160,7 @@ * safemode status as its parent folder? */ if (OPENBASEDIR_CHECKPATH(fullpath)) { + efree(fullpath); efree(file_dirname_fullpath); efree(file_basename); return 0; @@ -2026,7 +2027,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.30 2007/03/14 12:06:20 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.31 2007/03/14 15:02:20 iliaa Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
On 3/14/07, Ilia Alshanetsky [EMAIL PROTECTED] wrote: iliaa Wed Mar 14 15:02:20 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: Fixed a possible memory leak on open_basedir validation Thanks! Please don't forget to merge in HEAD :) --Pierre -- 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/zip php_zip.c /ext/zip/tests bug40228.phpt bug40228.zip
pajoye Mon Jan 29 15:25:06 2007 UTC Added files: (Branch: PHP_5_2) /php-src/ext/zip/tests bug40228.phpt bug40228.zip Modified files: /php-src/ext/zipphp_zip.c Log: - #40228, ZipArchive::extractTo does create empty directories recursively http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.26r2=1.1.2.27diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.26 php-src/ext/zip/php_zip.c:1.1.2.27 --- php-src/ext/zip/php_zip.c:1.1.2.26 Sun Jan 7 03:12:14 2007 +++ php-src/ext/zip/php_zip.c Mon Jan 29 15:25:06 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.26 2007/01/07 03:12:14 iliaa Exp $ */ +/* $Id: php_zip.c,v 1.1.2.27 2007/01/29 15:25:06 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -106,27 +106,32 @@ char *file_basename; size_t file_basename_len; + int is_dir_only = 0; if (file_len = MAXPATHLEN || zip_stat(za, file, 0, sb)) { return 0; } - memcpy(file_dirname, file, file_len); - - dir_len = php_dirname(file_dirname, file_len); - - if (dir_len 0) { - len = spprintf(file_dirname_fullpath, 0, %s/%s, dest, file_dirname); + if (file_len 1 file[file_len - 1] == '/') { + len = spprintf(file_dirname_fullpath, 0, %s/%s, dest, file); + is_dir_only = 1; } else { - len = spprintf(file_dirname_fullpath, 0, %s, dest); - } + memcpy(file_dirname, file, file_len); + dir_len = php_dirname(file_dirname, file_len); - php_basename(file, file_len, NULL, 0, file_basename, file_basename_len TSRMLS_CC); + if (dir_len 0) { + len = spprintf(file_dirname_fullpath, 0, %s/%s, dest, file_dirname); + } else { + len = spprintf(file_dirname_fullpath, 0, %s, dest); + } - if (SAFEMODE_CHECKFILE(file_dirname_fullpath)) { - efree(file_dirname_fullpath); - efree(file_basename); - return 0; + php_basename(file, file_len, NULL, 0, file_basename, (unsigned int *)file_basename_len TSRMLS_CC); + + if (SAFEMODE_CHECKFILE(file_dirname_fullpath)) { + efree(file_dirname_fullpath); + efree(file_basename); + return 0; + } } /* let see if the path already exists */ @@ -142,7 +147,9 @@ /* it is a standalone directory, job done */ if (file[file_len - 1] == '/') { efree(file_dirname_fullpath); - efree(file_basename); + if (!is_dir_only) { + efree(file_basename); + } return 1; } @@ -2009,7 +2016,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.26 2007/01/07 03:12:14 iliaa Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.27 2007/01/29 15:25:06 pajoye Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug40228.phpt?view=markuprev=1.1 Index: php-src/ext/zip/tests/bug40228.phpt +++ php-src/ext/zip/tests/bug40228.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug40228.zip?view=markuprev=1.1 Index: php-src/ext/zip/tests/bug40228.zip +++ php-src/ext/zip/tests/bug40228.zip -- 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/zip php_zip.c
nlopess Sat Jan 6 20:16:26 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: fix a few memleaks and double-free()s on error conditions http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.24r2=1.1.2.25diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.24 php-src/ext/zip/php_zip.c:1.1.2.25 --- php-src/ext/zip/php_zip.c:1.1.2.24 Mon Jan 1 09:36:10 2007 +++ php-src/ext/zip/php_zip.c Sat Jan 6 20:16:25 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.24 2007/01/01 09:36:10 sebastian Exp $ */ +/* $Id: php_zip.c,v 1.1.2.25 2007/01/06 20:16:25 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -551,7 +551,9 @@ if (zip_int) { if (zip_int-za) { - zip_close(zip_int-za); + if (zip_close(zip_int-za) != 0) { + _zip_free(zip_int-za); + } zip_int-za = NULL; } @@ -906,16 +908,20 @@ if (ze_obj-za) { /* we already have an opened zip, free it */ - zip_close(ze_obj-za); + if (zip_close(ze_obj-za) != 0) { + _zip_free(ze_obj-za); + } + ze_obj-za = NULL; } if (ze_obj-filename) { efree(ze_obj-filename); + ze_obj-filename = NULL; } intern = zip_open(resolved_path, flags, err); if (!intern || err) { RETURN_LONG((long)err); } - ze_obj-filename = estrndup(resolved_path, strlen(resolved_path)); + ze_obj-filename = estrdup(resolved_path); ze_obj-filename_len = filename_len; ze_obj-za = intern; RETURN_TRUE; @@ -2000,7 +2006,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.24 2007/01/01 09:36:10 sebastian Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.25 2007/01/06 20:16:25 nlopess Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
iliaa Sun Jan 7 03:12:14 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: Fixed memory leaks on error http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.25r2=1.1.2.26diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.25 php-src/ext/zip/php_zip.c:1.1.2.26 --- php-src/ext/zip/php_zip.c:1.1.2.25 Sat Jan 6 20:16:25 2007 +++ php-src/ext/zip/php_zip.c Sun Jan 7 03:12:14 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.25 2007/01/06 20:16:25 nlopess Exp $ */ +/* $Id: php_zip.c,v 1.1.2.26 2007/01/07 03:12:14 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -689,6 +689,7 @@ rsrc_int-index_current++; ZEND_REGISTER_RESOURCE(return_value, zr_rsrc, le_zip_entry); } else { + efree(zr_rsrc); RETURN_FALSE; } @@ -770,6 +771,7 @@ buffer[n] = 0; RETURN_STRINGL(buffer, n, 0); } else { + efree(buffer); RETURN_EMPTY_STRING() } } else { @@ -1815,6 +1817,7 @@ buffer = safe_emalloc(len, 1, 2); n = zip_fread(zf, buffer, len); if (n 1) { + efree(buffer); RETURN_EMPTY_STRING(); } @@ -2006,7 +2009,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.25 2007/01/06 20:16:25 nlopess Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.26 2007/01/07 03:12:14 iliaa Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
tony2001Mon Dec 25 22:40:23 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: MFH http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.22r2=1.1.2.23diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.22 php-src/ext/zip/php_zip.c:1.1.2.23 --- php-src/ext/zip/php_zip.c:1.1.2.22 Sun Dec 24 01:29:20 2006 +++ php-src/ext/zip/php_zip.c Mon Dec 25 22:40:23 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.22 2006/12/24 01:29:20 bjori Exp $ */ +/* $Id: php_zip.c,v 1.1.2.23 2006/12/25 22:40:23 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1086,8 +1086,8 @@ ze_obj-buffers_cnt++; pos = 0; } - ze_obj-buffers[pos] = (char *)emalloc(buffer_len); - memcpy(ze_obj-buffers[pos], buffer, buffer_len); + ze_obj-buffers[pos] = (char *)emalloc(buffer_len + 1); + memcpy(ze_obj-buffers[pos], buffer, buffer_len + 1); zs = zip_source_buffer(intern, ze_obj-buffers[pos], buffer_len, 0); @@ -2000,7 +2000,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.22 2006/12/24 01:29:20 bjori Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.23 2006/12/25 22:40:23 tony2001 Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
bjori Sun Dec 24 01:29:20 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: Fix typo http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.21r2=1.1.2.22diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.21 php-src/ext/zip/php_zip.c:1.1.2.22 --- php-src/ext/zip/php_zip.c:1.1.2.21 Sat Dec 23 23:28:39 2006 +++ php-src/ext/zip/php_zip.c Sun Dec 24 01:29:20 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.21 2006/12/23 23:28:39 iliaa Exp $ */ +/* $Id: php_zip.c,v 1.1.2.22 2006/12/24 01:29:20 bjori Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1720,7 +1720,7 @@ break; case IS_STRING: file = Z_STRVAL_PP(zval_file); - if (!php_zip_extract_file(intern, pathto, file, Z_STRLEN_P(zval_files) TSRMLS_CC)) { + if (!php_zip_extract_file(intern, pathto, file, Z_STRLEN_PP(zval_file) TSRMLS_CC)) { RETURN_FALSE; } break; @@ -2000,7 +2000,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.21 2006/12/23 23:28:39 iliaa Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.22 2006/12/24 01:29:20 bjori Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
pajoye Tue Nov 28 01:31:53 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - fix warning - addEmptyDir returns true on success - remove useless semi column http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.19r2=1.1.2.20diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.19 php-src/ext/zip/php_zip.c:1.1.2.20 --- php-src/ext/zip/php_zip.c:1.1.2.19 Sun Nov 12 00:31:03 2006 +++ php-src/ext/zip/php_zip.c Tue Nov 28 01:31:53 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.19 2006/11/12 00:31:03 nlopess Exp $ */ +/* $Id: php_zip.c,v 1.1.2.20 2006/11/28 01:31:53 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -122,7 +122,7 @@ len = spprintf(file_dirname_fullpath, 0, %s, dest); } - php_basename(file, file_len, NULL, 0, file_basename, file_basename_len TSRMLS_CC); + php_basename(file, file_len, NULL, 0, file_basename, (int *)file_basename_len TSRMLS_CC); if (SAFEMODE_CHECKFILE(file_dirname_fullpath)) { efree(file_dirname_fullpath); @@ -954,7 +954,7 @@ /* {{{ proto bool createEmptyDir(string dirname) U Returns the index of the entry named filename in the archive */ -ZIPARCHIVE_METHOD(addEmptyDir) +static ZIPARCHIVE_METHOD(addEmptyDir) { struct zip *intern; zval *this = getThis(); @@ -978,6 +978,7 @@ if (zip_add_dir(intern, (const char *)dirname) 0) { RETURN_FALSE; } + RETURN_TRUE; } /* }}} */ @@ -1004,7 +1005,6 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sll, filename, filename_len, entry_name, entry_name_len, offset_start, offset_len) == FAILURE) { - WRONG_PARAM_COUNT; return; } @@ -1375,7 +1375,7 @@ ZIP_FROM_OBJECT(intern, this); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, - name, name_len, flags) == FAILURE) {; + name, name_len, flags) == FAILURE) { return; } if (name_len 1) { @@ -2001,7 +2001,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.19 2006/11/12 00:31:03 nlopess Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.20 2006/11/28 01:31:53 pajoye Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c /ext/zip/lib zip_fclose.c
nlopess Sat Nov 11 23:43:00 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c /php-src/ext/zip/libzip_fclose.c Log: fix leaks within zip entries in several tests http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.17r2=1.1.2.18diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.17 php-src/ext/zip/php_zip.c:1.1.2.18 --- php-src/ext/zip/php_zip.c:1.1.2.17 Thu Nov 9 16:04:34 2006 +++ php-src/ext/zip/php_zip.c Sat Nov 11 23:43:00 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.17 2006/11/09 16:04:34 nlopess Exp $ */ +/* $Id: php_zip.c,v 1.1.2.18 2006/11/11 23:43:00 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -551,6 +551,7 @@ if (zip_int) { if (zip_int-za) { zip_close(zip_int-za); + zip_int-za = NULL; } efree(rsrc-ptr); @@ -565,8 +566,14 @@ { zip_read_rsrc *zr_rsrc = (zip_read_rsrc *) rsrc-ptr; - efree(zr_rsrc); - rsrc-ptr = NULL; + if (zr_rsrc) { + if (zr_rsrc-zf) { + zip_fclose(zr_rsrc-zf); + zr_rsrc-zf = NULL; + } + efree(zr_rsrc); + rsrc-ptr = NULL; + } } /* }}} */ @@ -1992,7 +1999,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.17 2006/11/09 16:04:34 nlopess Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.18 2006/11/11 23:43:00 nlopess Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_fclose.c?r1=1.1r2=1.1.2.1diff_format=u Index: php-src/ext/zip/lib/zip_fclose.c diff -u php-src/ext/zip/lib/zip_fclose.c:1.1 php-src/ext/zip/lib/zip_fclose.c:1.1.2.1 --- php-src/ext/zip/lib/zip_fclose.c:1.1Mon Jul 24 16:58:58 2006 +++ php-src/ext/zip/lib/zip_fclose.cSat Nov 11 23:43:00 2006 @@ -52,13 +52,15 @@ free(zf-buffer); free(zf-zstr); -for (i=0; izf-za-nfile; i++) { - if (zf-za-file[i] == zf) { - zf-za-file[i] = zf-za-file[zf-za-nfile-1]; - zf-za-nfile--; - break; + if (zf-za) { + for (i=0; izf-za-nfile; i++) { + if (zf-za-file[i] == zf) { + zf-za-file[i] = zf-za-file[zf-za-nfile-1]; + zf-za-nfile--; + break; + } + } } -} ret = 0; if (zf-error.zip_err) -- 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/zip php_zip.c
nlopess Sun Nov 12 00:31:04 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: fix leak in the object destrucotr when zip_close() fails (fixes oo_delete.phpt) http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.18r2=1.1.2.19diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.18 php-src/ext/zip/php_zip.c:1.1.2.19 --- php-src/ext/zip/php_zip.c:1.1.2.18 Sat Nov 11 23:43:00 2006 +++ php-src/ext/zip/php_zip.c Sun Nov 12 00:31:03 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.18 2006/11/11 23:43:00 nlopess Exp $ */ +/* $Id: php_zip.c,v 1.1.2.19 2006/11/12 00:31:03 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -490,7 +490,9 @@ return; } if (intern-za) { - zip_close(intern-za); + if (zip_close(intern-za) != 0) { + _zip_free(intern-za); + } intern-za = NULL; } @@ -1999,7 +2001,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.18 2006/11/11 23:43:00 nlopess Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.19 2006/11/12 00:31:03 nlopess Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c /ext/zip/tests 38943.phpt
pajoye Sun Sep 24 22:27:57 2006 UTC Added files: (Branch: PHP_5_2) /php-src/ext/zip/tests 38943.phpt Modified files: /php-src/ext/zipphp_zip.c Log: - #38943, properties in extended class cannot be set - use zend_object_std_init instead of a manual initialisation http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.14r2=1.1.2.15diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.14 php-src/ext/zip/php_zip.c:1.1.2.15 --- php-src/ext/zip/php_zip.c:1.1.2.14 Fri Sep 15 12:12:25 2006 +++ php-src/ext/zip/php_zip.c Sun Sep 24 22:27:57 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.14 2006/09/15 12:12:25 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.15 2006/09/24 22:27:57 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -526,7 +526,6 @@ intern = emalloc(sizeof(ze_zip_object)); memset(intern-zo, 0, sizeof(zend_object)); - intern-zo.ce = class_type; intern-za = NULL; intern-buffers = NULL; @@ -534,8 +533,7 @@ intern-buffers_cnt = 0; intern-prop_handler = zip_prop_handlers; - ALLOC_HASHTABLE(intern-zo.properties); - zend_hash_init(intern-zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); + zend_object_std_init(intern-zo, class_type TSRMLS_CC); zend_hash_copy(intern-zo.properties, class_type-default_properties, (copy_ctor_func_t) zval_add_ref, (void *) tmp, sizeof(zval *)); @@ -1895,7 +1893,6 @@ memcpy(zip_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); zip_object_handlers.clone_obj = NULL; zip_object_handlers.get_property_ptr_ptr = php_zip_get_property_ptr_ptr; - zip_object_handlers.write_property = NULL; zip_object_handlers.get_properties = php_zip_get_properties; zip_object_handlers.read_property = php_zip_read_property; @@ -1987,7 +1984,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.14 2006/09/15 12:12:25 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.15 2006/09/24 22:27:57 pajoye Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/38943.phpt?view=markuprev=1.1 Index: php-src/ext/zip/tests/38943.phpt +++ php-src/ext/zip/tests/38943.phpt --TEST-- #38943, properties in extended class cannot be set --SKIPIF-- ?php /* $Id: 38943.phpt,v 1.1 2006/09/24 22:27:20 pajoye Exp $ */ if(!extension_loaded('zip')) die('skip'); ? --FILE-- ?php class myZip extends ZipArchive { private $test = 0; public $testp = 1; private $testarray = array(); public function __construct() { $this-testarray[] = 1; var_dump($this-testarray); } } $z = new myZip; $z-testp = foobar; var_dump($z); ? --EXPECTF-- array(1) { [0]= int(1) } object(myZip)#1 (%d) { [test:private]= int(0) [testp]= string(6) foobar [testarray:private]= array(1) { [0]= int(1) } [status]= int(0) [statusSys]= int(0) [numFiles]= int(0) [filename]= string(0) [comment]= string(0) } -- 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/zip php_zip.c /ext/zip/tests bug8700.phpt
pajoye Fri Sep 15 12:12:25 2006 UTC Added files: (Branch: PHP_5_2) /php-src/ext/zip/tests bug8700.phpt Modified files: /php-src/ext/zipphp_zip.c Log: - MFH: PECL Bug #8700, zipArchive::getFromIndex() fails http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.13r2=1.1.2.14diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.13 php-src/ext/zip/php_zip.c:1.1.2.14 --- php-src/ext/zip/php_zip.c:1.1.2.13 Tue Sep 12 12:02:49 2006 +++ php-src/ext/zip/php_zip.c Fri Sep 15 12:12:25 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.13 2006/09/12 12:02:49 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.14 2006/09/15 12:12:25 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1744,7 +1744,7 @@ char *filename; int filename_len; - long index; + long index = -1; long flags = 0; long len = 0; @@ -1778,8 +1778,12 @@ if (len 1) { len = sb.size; } + if (index = 0) { + zf = zip_fopen_index(intern, index, flags); + } else { + zf = zip_fopen(intern, filename, flags); + } - zf = zip_fopen(intern, filename, flags); if (zf == NULL) { RETURN_FALSE; } @@ -1983,7 +1987,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.13 2006/09/12 12:02:49 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.14 2006/09/15 12:12:25 pajoye Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug8700.phpt?view=markuprev=1.1 Index: php-src/ext/zip/tests/bug8700.phpt +++ php-src/ext/zip/tests/bug8700.phpt --TEST-- bug #8700, getFromIndex(0) fails --SKIPIF-- ?php /* $Id: bug8700.phpt,v 1.1 2006/09/15 12:10:50 pajoye Exp $ */ if(!extension_loaded('zip')) die('skip'); ? --FILE-- ?php $thisdir = dirname(__FILE__); $filename = $thisdir . /bug8009.zip; $zip = new ZipArchive(); if ($zip-open($filename) === FALSE) { exit(cannot open $filename\n); } $contents_from_idx = $zip-getFromIndex(0); $contents_from_name = $zip-getFromName('1.txt'); if ($contents_from_idx != $contents_from_name) { echo failed:; var_dump($content_from_idx, $content_from_name); } $zip-close(); echo status: . $zip-status . \n; echo \n; --EXPECT-- status: 0 -- 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/zip php_zip.c
pajoye Tue Sep 12 12:02:49 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - PECL Bug #8676, addFile was not updated and still used VCWD_REALPATH, it now uses expand_filepath http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.12r2=1.1.2.13diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.12 php-src/ext/zip/php_zip.c:1.1.2.13 --- php-src/ext/zip/php_zip.c:1.1.2.12 Wed Sep 6 17:38:36 2006 +++ php-src/ext/zip/php_zip.c Tue Sep 12 12:02:49 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.12 2006/09/06 17:38:36 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.13 2006/09/12 12:02:49 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -996,7 +996,7 @@ RETURN_FALSE; } - if (!VCWD_REALPATH(filename, resolved_path)) { + if (!expand_filepath(filename, resolved_path TSRMLS_CC)) { RETURN_FALSE; } @@ -1983,7 +1983,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.12 2006/09/06 17:38:36 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.13 2006/09/12 12:02:49 pajoye Exp $); php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
pajoye Wed Sep 6 13:03:55 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - MFH: zip_open takes only one parameter (Thx Nuno L.) http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.8r2=1.1.2.9diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.8 php-src/ext/zip/php_zip.c:1.1.2.9 --- php-src/ext/zip/php_zip.c:1.1.2.8 Sat Aug 26 12:23:43 2006 +++ php-src/ext/zip/php_zip.c Wed Sep 6 13:03:55 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.8 2006/08/26 12:23:43 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.9 2006/09/06 13:03:55 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -608,17 +608,16 @@ ZEND_GET_MODULE(zip) #endif -/* {{{ proto resource zip_open(string filename [,flags]) +/* {{{ proto resource zip_open(string filename) Create new zip using source uri for output */ PHP_FUNCTION(zip_open) { char *filename; int filename_len; zip_rsrc *rsrc_int; - long mode = 0; int err = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, filename, filename_len, mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, filename, filename_len) == FAILURE) { return; } if (SAFEMODE_CHECKFILE(filename)) { @@ -627,7 +626,7 @@ rsrc_int = (zip_rsrc *)emalloc(sizeof(zip_rsrc)); - rsrc_int-za = zip_open(filename, mode, err); + rsrc_int-za = zip_open(filename, 0, err); if (rsrc_int-za == NULL) { efree(rsrc_int); RETURN_LONG((long)err); @@ -1982,7 +1981,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.8 2006/08/26 12:23:43 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.9 2006/09/06 13:03:55 pajoye Exp $); php_info_print_table_row(2, Zip version, 1.7.1); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
pajoye Wed Sep 6 17:38:36 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - bump version, 5.2.0 will have zip-2.0.0-stable http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.11r2=1.1.2.12diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.11 php-src/ext/zip/php_zip.c:1.1.2.12 --- php-src/ext/zip/php_zip.c:1.1.2.11 Wed Sep 6 17:24:41 2006 +++ php-src/ext/zip/php_zip.c Wed Sep 6 17:38:36 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.11 2006/09/06 17:24:41 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.12 2006/09/06 17:38:36 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1983,8 +1983,8 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.11 2006/09/06 17:24:41 pajoye Exp $); - php_info_print_table_row(2, Zip version, 1.7.1); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.12 2006/09/06 17:38:36 pajoye Exp $); + php_info_print_table_row(2, Zip version, 2.0.0); php_info_print_table_row(2, Libzip version, 0.7.1); php_info_print_table_end(); -- 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/zip php_zip.c
pajoye Wed Sep 6 17:24:41 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - wrong cast, strlen is int http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.10r2=1.1.2.11diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.10 php-src/ext/zip/php_zip.c:1.1.2.11 --- php-src/ext/zip/php_zip.c:1.1.2.10 Wed Sep 6 15:19:41 2006 +++ php-src/ext/zip/php_zip.c Wed Sep 6 17:24:41 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.10 2006/09/06 15:19:41 nlopess Exp $ */ +/* $Id: php_zip.c,v 1.1.2.11 2006/09/06 17:24:41 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1273,7 +1273,7 @@ } comment = zip_get_archive_comment(intern, comment_len, (int)flags); - RETURN_STRINGL((char *)comment, (long)comment_len, 1); + RETURN_STRINGL((char *)comment, comment_len, 1); } /* }}} */ @@ -1360,7 +1360,7 @@ PHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb); comment = zip_get_file_comment(intern, sb.index, comment_len, (int)flags); - RETURN_STRINGL((char *)comment, (long)comment_len, 1); + RETURN_STRINGL((char *)comment, comment_len, 1); } /* }}} */ @@ -1389,7 +1389,7 @@ PHP_ZIP_STAT_INDEX(intern, index, 0, sb); comment = zip_get_file_comment(intern, index, comment_len, (int)flags); - RETURN_STRINGL((char *)comment, (long)comment_len, 1); + RETURN_STRINGL((char *)comment, comment_len, 1); } /* }}} */ @@ -1983,7 +1983,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.10 2006/09/06 15:19:41 nlopess Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.11 2006/09/06 17:24:41 pajoye Exp $); php_info_print_table_row(2, Zip version, 1.7.1); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
pajoye Sat Aug 26 12:23:43 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - don't rely/use VCWD_REALPATH, use expand_filepath instead NB: that'd to be true for all this VCWD mess http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.7r2=1.1.2.8diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.7 php-src/ext/zip/php_zip.c:1.1.2.8 --- php-src/ext/zip/php_zip.c:1.1.2.7 Fri Aug 25 16:03:00 2006 +++ php-src/ext/zip/php_zip.c Sat Aug 26 12:23:43 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.7 2006/08/25 16:03:00 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.8 2006/08/26 12:23:43 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -905,7 +905,7 @@ RETURN_FALSE; } - if (!VCWD_REALPATH(filename, resolved_path)) { + if (!expand_filepath(filename, resolved_path TSRMLS_CC)) { RETURN_FALSE; } @@ -1982,7 +1982,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.7 2006/08/25 16:03:00 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.8 2006/08/26 12:23:43 pajoye Exp $); php_info_print_table_row(2, Zip version, 1.7.1); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
I missed the discussion about this. Is there a bug in VCWD_REALPATH()? Can you explain? Thanks. -Original Message- From: Pierre-Alain Joye [mailto:[EMAIL PROTECTED] Sent: Saturday, August 26, 2006 5:24 AM To: php-cvs@lists.php.net Subject: [PHP-CVS] cvs: php-src(PHP_5_2) /ext/zip php_zip.c pajoyeSat Aug 26 12:23:43 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zip php_zip.c Log: - don't rely/use VCWD_REALPATH, use expand_filepath instead NB: that'd to be true for all this VCWD mess http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1 .2.7r2=1.1.2.8diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.7 php-src/ext/zip/php_zip.c:1.1.2.8 --- php-src/ext/zip/php_zip.c:1.1.2.7 Fri Aug 25 16:03:00 2006 +++ php-src/ext/zip/php_zip.c Sat Aug 26 12:23:43 2006 @@ -16,7 +16,7 @@ +- -+ */ -/* $Id: php_zip.c,v 1.1.2.7 2006/08/25 16:03:00 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.8 2006/08/26 12:23:43 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -905,7 +905,7 @@ RETURN_FALSE; } - if (!VCWD_REALPATH(filename, resolved_path)) { + if (!expand_filepath(filename, resolved_path TSRMLS_CC)) { RETURN_FALSE; } @@ -1982,7 +1982,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.7 2006/08/25 16:03:00 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v +1.1.2.8 2006/08/26 12:23:43 pajoye Exp $); php_info_print_table_row(2, Zip version, 1.7.1); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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(PHP_5_2) /ext/zip php_zip.c
pajoye Fri Aug 25 16:03:00 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - bundled matches pecl 1.7.1 http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.6r2=1.1.2.7diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.6 php-src/ext/zip/php_zip.c:1.1.2.7 --- php-src/ext/zip/php_zip.c:1.1.2.6 Thu Aug 24 16:37:14 2006 +++ php-src/ext/zip/php_zip.c Fri Aug 25 16:03:00 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.6 2006/08/24 16:37:14 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.7 2006/08/25 16:03:00 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1982,8 +1982,8 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.6 2006/08/24 16:37:14 pajoye Exp $); - php_info_print_table_row(2, Zip version, 1.4.0); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.7 2006/08/25 16:03:00 pajoye Exp $); + php_info_print_table_row(2, Zip version, 1.7.1); php_info_print_table_row(2, Libzip version, 0.7.1); php_info_print_table_end(); -- 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/zip php_zip.c
pajoye Thu Aug 24 16:37:14 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - solve the relative path issues in TS environment http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.5r2=1.1.2.6diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.5 php-src/ext/zip/php_zip.c:1.1.2.6 --- php-src/ext/zip/php_zip.c:1.1.2.5 Mon Aug 14 15:07:52 2006 +++ php-src/ext/zip/php_zip.c Thu Aug 24 16:37:14 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.5 2006/08/14 15:07:52 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.6 2006/08/24 16:37:14 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -885,6 +885,7 @@ int filename_len; int err = 0; long flags = 0; + char resolved_path[MAXPATHLEN + 1]; zval *this = getThis(); ze_zip_object *ze_obj = NULL; @@ -903,6 +904,11 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, Empty string as source); RETURN_FALSE; } + + if (!VCWD_REALPATH(filename, resolved_path)) { + RETURN_FALSE; + } + if (ze_obj-za) { /* we already have an opened zip, free it */ zip_close(ze_obj-za); @@ -910,12 +916,11 @@ if (ze_obj-filename) { efree(ze_obj-filename); } - - intern = zip_open(filename, flags, err); + intern = zip_open(resolved_path, flags, err); if (!intern || err) { RETURN_LONG((long)err); } - ze_obj-filename = estrndup(filename, filename_len); + ze_obj-filename = estrndup(resolved_path, strlen(resolved_path)); ze_obj-filename_len = filename_len; ze_obj-za = intern; RETURN_TRUE; @@ -964,6 +969,7 @@ struct zip_source *zs; long offset_start = 0, offset_len = 0; int cur_idx; + char resolved_path[MAXPATHLEN + 1]; if (!this) { RETURN_FALSE; @@ -991,7 +997,11 @@ RETURN_FALSE; } - zs = zip_source_file(intern, filename, 0, 0); + if (!VCWD_REALPATH(filename, resolved_path)) { + RETURN_FALSE; + } + + zs = zip_source_file(intern, resolved_path, 0, 0); if (!zs) { RETURN_FALSE; } @@ -1972,7 +1982,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.5 2006/08/14 15:07:52 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.6 2006/08/24 16:37:14 pajoye Exp $); php_info_print_table_row(2, Zip version, 1.4.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c
pajoye Mon Aug 14 15:07:52 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: - nuke unused parameter (not present in old versions) http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.4r2=1.1.2.5diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.4 php-src/ext/zip/php_zip.c:1.1.2.5 --- php-src/ext/zip/php_zip.c:1.1.2.4 Sun Aug 13 23:43:11 2006 +++ php-src/ext/zip/php_zip.c Mon Aug 14 15:07:52 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.4 2006/08/13 23:43:11 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.5 2006/08/14 15:07:52 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -657,17 +657,16 @@ } /* }}} */ -/* {{{ proto resource zip_read(resource zip [, int flags]) +/* {{{ proto resource zip_read(resource zip) Returns the next file in the archive */ PHP_FUNCTION(zip_read) { zval *zip_dp; zip_read_rsrc *zr_rsrc; int ret; - long flags = 0; zip_rsrc *rsrc_int; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|l, zip_dp, flags) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r, zip_dp) == FAILURE) { return; } ZEND_FETCH_RESOURCE(rsrc_int, zip_rsrc *, zip_dp, -1, le_zip_dir_name, le_zip_dir); @@ -679,7 +678,7 @@ zr_rsrc = emalloc(sizeof(zip_read_rsrc)); - ret = zip_stat_index(rsrc_int-za, rsrc_int-index_current, flags, zr_rsrc-sb); + ret = zip_stat_index(rsrc_int-za, rsrc_int-index_current, 0, zr_rsrc-sb); if (ret != 0) { efree(zr_rsrc); @@ -745,17 +744,17 @@ } /* }}} */ -/* {{{ proto mixed zip_entry_read(resource zip_entry [, int len [, int mode]]) +/* {{{ proto mixed zip_entry_read(resource zip_entry [, int len]) Read from an open directory entry */ PHP_FUNCTION(zip_entry_read) { zval * zip_entry; - long len = 0, mode = 0; + long len = 0; zip_read_rsrc * zr_rsrc; char *buffer; int n = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|ll, zip_entry, len, mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|l, zip_entry, len) == FAILURE) { return; } @@ -1973,7 +1972,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.4 2006/08/13 23:43:11 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.5 2006/08/14 15:07:52 pajoye Exp $); php_info_print_table_row(2, Zip version, 1.4.0); php_info_print_table_row(2, Libzip version, 0.7.1); -- 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/zip php_zip.c /ext/zip/lib zip.h zip_open.c zip_replace.c
pajoye Sun Aug 13 21:09:59 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c /php-src/ext/zip/libzip.h zip_open.c zip_replace.c Log: - MFP: - add overwrite mode to ZipArchive::open, always starts a new archive - Fix safe mode checks on extract - Fix possible leaks when a safe mode error has been raised http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.2r2=1.1.2.3diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.2 php-src/ext/zip/php_zip.c:1.1.2.3 --- php-src/ext/zip/php_zip.c:1.1.2.2 Sun Aug 13 00:52:59 2006 +++ php-src/ext/zip/php_zip.c Sun Aug 13 21:09:59 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.2 2006/08/13 00:52:59 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.3 2006/08/13 21:09:59 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -113,7 +113,11 @@ php_basename(file, file_len, NULL, 0, file_basename, file_basename_len TSRMLS_CC); - SAFEMODE_CHECKFILE(file_dirname_fullpath); + if (SAFEMODE_CHECKFILE(file_dirname_fullpath)) { + efree(file_dirname_fullpath); + efree(file_basename); + return 0; + } /* let see if the path already exists */ if (php_stream_stat_path(file_dirname_fullpath, ssb) 0) { @@ -143,7 +147,11 @@ * is required, does a file can have a different * safemode status as its parent folder? */ - SAFEMODE_CHECKFILE(fullpath); + if (SAFEMODE_CHECKFILE(fullpath)) { + efree(file_dirname_fullpath); + efree(file_basename); + return 0; + } zf = zip_fopen(za, file, 0); if (zf == NULL) { @@ -1880,6 +1888,8 @@ REGISTER_ZIP_CLASS_CONST_LONG(CREATE, ZIP_CREATE); REGISTER_ZIP_CLASS_CONST_LONG(EXCL, ZIP_EXCL); REGISTER_ZIP_CLASS_CONST_LONG(CHECKCONS, ZIP_CHECKCONS); + REGISTER_ZIP_CLASS_CONST_LONG(OVERWRITE, ZIP_OVERWRITE); + REGISTER_ZIP_CLASS_CONST_LONG(FL_NOCASE, ZIP_FL_NOCASE); REGISTER_ZIP_CLASS_CONST_LONG(FL_NODIR, ZIP_FL_NODIR); REGISTER_ZIP_CLASS_CONST_LONG(FL_COMPRESSED, ZIP_FL_COMPRESSED); @@ -1951,7 +1961,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.2 2006/08/13 00:52:59 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.3 2006/08/13 21:09:59 pajoye Exp $); php_info_print_table_row(2, Zip version, 1.4.0); php_info_print_table_row(2, Libzip version, 0.7.1); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip.h?r1=1.1r2=1.1.2.1diff_format=u Index: php-src/ext/zip/lib/zip.h diff -u php-src/ext/zip/lib/zip.h:1.1 php-src/ext/zip/lib/zip.h:1.1.2.1 --- php-src/ext/zip/lib/zip.h:1.1 Mon Jul 24 16:58:58 2006 +++ php-src/ext/zip/lib/zip.h Sun Aug 13 21:09:59 2006 @@ -53,6 +53,7 @@ #define ZIP_CREATE 1 #define ZIP_EXCL 2 #define ZIP_CHECKCONS4 +#define ZIP_OVERWRITE8 /* flags for zip_name_locate, zip_fopen, zip_stat, ... */ http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_open.c?r1=1.1r2=1.1.2.1diff_format=u Index: php-src/ext/zip/lib/zip_open.c diff -u php-src/ext/zip/lib/zip_open.c:1.1 php-src/ext/zip/lib/zip_open.c:1.1.2.1 --- php-src/ext/zip/lib/zip_open.c:1.1 Mon Jul 24 16:58:58 2006 +++ php-src/ext/zip/lib/zip_open.c Sun Aug 13 21:09:59 2006 @@ -74,9 +74,9 @@ set_error(zep, NULL, ZIP_ER_INVAL); return NULL; } - -if (stat(fn, st) != 0) { - if (flags ZIP_CREATE) { + +if (flags ZIP_OVERWRITE || stat(fn, st) != 0) { + if ((flags ZIP_CREATE) || (flags ZIP_OVERWRITE)) { if ((za=_zip_new(error)) == NULL) { set_error(zep, error, 0); return NULL; @@ -99,14 +99,15 @@ set_error(zep, NULL, ZIP_ER_EXISTS); return NULL; } + + /* ZIP_CREATE gets ignored if file exists and not ZIP_EXCL, just like open() */ - -if ((fp=fopen(fn, rb)) == NULL) { - set_error(zep, NULL, ZIP_ER_OPEN); - return NULL; -} - + if ((fp=fopen(fn, rb)) == NULL) { + set_error(zep, NULL, ZIP_ER_OPEN); + return NULL; + } + clearerr(fp); fseek(fp, 0, SEEK_END); len = ftell(fp); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/lib/zip_replace.c?r1=1.1r2=1.1.2.1diff_format=u Index: php-src/ext/zip/lib/zip_replace.c diff -u php-src/ext/zip/lib/zip_replace.c:1.1 php-src/ext/zip/lib/zip_replace.c:1.1.2.1 --- php-src/ext/zip/lib/zip_replace.c:1.1 Mon Jul 24 16:58:58 2006 +++ php-src/ext/zip/lib/zip_replace.c Sun Aug 13 21:09:59 2006 @@ -66,11 +66,14 @@ return -1; idx =
[PHP-CVS] cvs: php-src(PHP_5_2) /ext/zip php_zip.c /ext/zip/tests oo_namelocate.phpt
pajoye Sun Aug 13 23:43:11 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c /php-src/ext/zip/tests oo_namelocate.phpt Log: - MFH: locateName should not change the state/error, can be used to test an entry http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1.2.3r2=1.1.2.4diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1.2.3 php-src/ext/zip/php_zip.c:1.1.2.4 --- php-src/ext/zip/php_zip.c:1.1.2.3 Sun Aug 13 21:09:59 2006 +++ php-src/ext/zip/php_zip.c Sun Aug 13 23:43:11 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1.2.3 2006/08/13 21:09:59 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.4 2006/08/13 23:43:11 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1153,6 +1153,7 @@ char *name; int name_len; long flags = 0; + long idx = -1; if (!this) { RETURN_FALSE; @@ -1169,7 +1170,18 @@ RETURN_FALSE; } - RETURN_LONG((long)zip_name_locate(intern, (const char *)name, flags)) + idx = (long)zip_name_locate(intern, (const char *)name, flags); + + if (idx0) { + /* reset the error */ + if (intern-error.str) { + _zip_error_fini(intern-error); + } + _zip_error_init(intern-error); + RETURN_FALSE; + } else { + RETURN_LONG(idx); + } } /* }}} */ @@ -1961,7 +1973,7 @@ php_info_print_table_start(); php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.3 2006/08/13 21:09:59 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.4 2006/08/13 23:43:11 pajoye Exp $); php_info_print_table_row(2, Zip version, 1.4.0); php_info_print_table_row(2, Libzip version, 0.7.1); http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/oo_namelocate.phpt?r1=1.1r2=1.1.2.1diff_format=u Index: php-src/ext/zip/tests/oo_namelocate.phpt diff -u php-src/ext/zip/tests/oo_namelocate.phpt:1.1 php-src/ext/zip/tests/oo_namelocate.phpt:1.1.2.1 --- php-src/ext/zip/tests/oo_namelocate.phpt:1.1Mon Jul 24 16:58:58 2006 +++ php-src/ext/zip/tests/oo_namelocate.phptSun Aug 13 23:43:11 2006 @@ -2,7 +2,7 @@ Locate entries by name --SKIPIF-- ?php -/* $Id: oo_namelocate.phpt,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +/* $Id: oo_namelocate.phpt,v 1.1.2.1 2006/08/13 23:43:11 pajoye Exp $ */ if(!extension_loaded('zip')) die('skip'); ? --FILE-- @@ -31,15 +31,16 @@ exit('failed'); } -echo $zip-locateName('entry1.txt') . \n; -echo $zip-locateName('eNtry2.txt') . \n; -echo $zip-locateName('eNtry2.txt', ZIPARCHIVE::FL_NOCASE) . \n; -echo $zip-locateName('enTRy2d.txt', ZIPARCHIVE::FL_NOCASE|ZIPARCHIVE::FL_NODIR) . \n; + +var_dump($zip-locateName('entry1.txt')); +var_dump($zip-locateName('eNtry2.txt')); +var_dump($zip-locateName('eNtry2.txt', ZIPARCHIVE::FL_NOCASE)); +var_dump($zip-locateName('enTRy2d.txt', ZIPARCHIVE::FL_NOCASE|ZIPARCHIVE::FL_NODIR)); $zip-close(); ? --EXPECTF-- -0 --1 -1 -2 +int(0) +bool(false) +int(1) +int(2) -- 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/zip php_zip.c
iliaa Fri Jul 28 13:59:06 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/zipphp_zip.c Log: Cleanup phpinfo() output http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1r2=1.1.2.1diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.1 php-src/ext/zip/php_zip.c:1.1.2.1 --- php-src/ext/zip/php_zip.c:1.1 Mon Jul 24 16:58:58 2006 +++ php-src/ext/zip/php_zip.c Fri Jul 28 13:59:06 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.1 2006/07/24 16:58:58 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.1.2.1 2006/07/28 13:59:06 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1914,12 +1914,12 @@ PHP_MINFO_FUNCTION(zip) { php_info_print_table_start(); - { - php_info_print_table_row(2, Zip, enabled); - php_info_print_table_row(2, $Id: php_zip.c,v 1.1 2006/07/24 16:58:58 pajoye Exp $, enabled); - php_info_print_table_row(2, Zip version, 1.4.0); - php_info_print_table_row(2, Libzip version, 0.7.1); - } + + php_info_print_table_row(2, Zip, enabled); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.1.2.1 2006/07/28 13:59:06 iliaa Exp $); + php_info_print_table_row(2, Zip version, 1.4.0); + php_info_print_table_row(2, Libzip version, 0.7.1); + php_info_print_table_end(); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php