[PHP-CVS] cvs: php-src /ext/zip php_zip.c
iliaa Tue Feb 24 23:55:24 2009 UTC Modified files: /php-src/ext/zipphp_zip.c Log: MFB: Adjust previous fix http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.71r2=1.72diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.71 php-src/ext/zip/php_zip.c:1.72 --- php-src/ext/zip/php_zip.c:1.71 Sun Feb 22 17:55:01 2009 +++ php-src/ext/zip/php_zip.c Tue Feb 24 23:55:24 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.71 2009/02/22 17:55:01 iliaa Exp $ */ +/* $Id: php_zip.c,v 1.72 2009/02/24 23:55:24 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -779,6 +779,7 @@ } else { if (hnd-read_const_char_from_obj_func) { retchar = hnd-read_const_char_from_obj_func(obj TSRMLS_CC); + len = strlen(retchar); } } } @@ -2747,7 +2748,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.71 2009/02/22 17:55:01 iliaa Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.72 2009/02/24 23:55:24 iliaa 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 /ext/zip php_zip.c
pajoye Fri Jan 2 00:22:55 2009 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - MFB: fix filename property read http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.69r2=1.70diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.69 php-src/ext/zip/php_zip.c:1.70 --- php-src/ext/zip/php_zip.c:1.69 Wed Dec 31 11:12:38 2008 +++ php-src/ext/zip/php_zip.c Fri Jan 2 00:22:55 2009 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.69 2008/12/31 11:12:38 sebastian Exp $ */ +/* $Id: php_zip.c,v 1.70 2009/01/02 00:22:55 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -791,7 +791,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); } @@ -2745,7 +2745,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.69 2008/12/31 11:12:38 sebastian Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.70 2009/01/02 00:22:55 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 /ext/zip php_zip.c php_zip.h /ext/zip/tests bug14962.phpt bug38943.inc bug38943.phpt bug38943_2.phpt bug38944.phpt bug7658.phpt
pajoye Wed Nov 12 11:24:49 2008 UTC Added files: /php-src/ext/zip/tests bug14962.phpt Modified files: /php-src/ext/zipphp_zip.c php_zip.h /php-src/ext/zip/tests bug38943.inc bug38943_2.phpt bug38943.phpt bug38944.phpt bug7658.phpt Log: - fix #14962 (makes 2nd argument really optional) - replace ZEND_ENGINE_2_1 test with PHP_ZIP_USE_OO, version independent - sync tests with 5.3 http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.65r2=1.66diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.65 php-src/ext/zip/php_zip.c:1.66 --- php-src/ext/zip/php_zip.c:1.65 Sun Nov 2 21:10:12 2008 +++ php-src/ext/zip/php_zip.c Wed Nov 12 11:24:48 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.65 2008/11/02 21:10:12 felipe Exp $ */ +/* $Id: php_zip.c,v 1.66 2008/11/12 11:24:48 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -135,7 +135,7 @@ } /* }}} */ -#ifdef ZEND_ENGINE_2_1 +#ifdef PHP_ZIP_USE_OO /* {{{ php_zip_extract_file */ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int file_len TSRMLS_DC) { @@ -740,7 +740,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; @@ -760,7 +760,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; @@ -1423,7 +1423,7 @@ } /* }}} */ -#ifdef ZEND_ENGINE_2_1 +#ifdef PHP_ZIP_USE_OO /* {{{ proto mixed ZipArchive::open(string source [, int flags]) U Create new zip using source uri for output, return TRUE on success or the error code */ static ZIPARCHIVE_METHOD(open) @@ -2413,15 +2413,15 @@ 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; -} -} + 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) { + if (zval_files (Z_TYPE_P(zval_files) != IS_NULL)) { switch (Z_TYPE_P(zval_files)) { case IS_UNICODE: if (FAILURE == php_stream_path_param_encode(zval_files, file, file_len, REPORT_ERRORS, FG(default_context))) { @@ -2443,6 +2443,7 @@ RETURN_FALSE; } break; + case IS_ARRAY: nelems = zend_hash_num_elements(Z_ARRVAL_P(zval_files)); if (nelems == 0 ) { @@ -2476,7 +2477,7 @@ } } break; - case IS_LONG: + default: php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid argument, expect string or array of strings); break; @@ -2659,7 +2660,7 @@ /* {{{ PHP_MINIT_FUNCTION */ static PHP_MINIT_FUNCTION(zip) { -#ifdef ZEND_ENGINE_2_1 +#ifdef PHP_ZIP_USE_OO zend_class_entry ce; memcpy(zip_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); @@ -2742,7 +2743,7 @@ */ static PHP_MSHUTDOWN_FUNCTION(zip) { -#ifdef ZEND_ENGINE_2_1 +#ifdef PHP_ZIP_USE_OO zend_hash_destroy(zip_prop_handlers); php_unregister_url_stream_wrapper(zip TSRMLS_CC); #endif @@ -2757,7 +2758,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.65 2008/11/02 21:10:12 felipe Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.66 2008/11/12 11:24:48 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.18r2=1.19diff_format=u Index: php-src/ext/zip/php_zip.h diff -u php-src/ext/zip/php_zip.h:1.18 php-src/ext/zip/php_zip.h:1.19 --- php-src/ext/zip/php_zip.h:1.18 Fri Aug 8 18:13:55 2008 +++ php-src/ext/zip/php_zip.h Wed Nov 12 11:24:48 2008 @@ -16,7
[PHP-CVS] cvs: php-src /ext/zip php_zip.c
felipe Wed Nov 12 17:26:19 2008 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - Removed unused variables http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.66r2=1.67diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.66 php-src/ext/zip/php_zip.c:1.67 --- php-src/ext/zip/php_zip.c:1.66 Wed Nov 12 11:24:48 2008 +++ php-src/ext/zip/php_zip.c Wed Nov 12 17:26:19 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.66 2008/11/12 11:24:48 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.67 2008/11/12 17:26:19 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -99,9 +99,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])) { @@ -2758,7 +2755,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.66 2008/11/12 11:24:48 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.67 2008/11/12 17:26:19 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 /ext/zip php_zip.c
pajoye Thu Oct 23 21:18:13 2008 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - MFB: flatten path and make them relative before extraction http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.62r2=1.63diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.62 php-src/ext/zip/php_zip.c:1.63 --- php-src/ext/zip/php_zip.c:1.62 Tue Oct 21 23:36:17 2008 +++ php-src/ext/zip/php_zip.c Thu Oct 23 21:18:13 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.62 2008/10/21 23:36:17 lbarnaud Exp $ */ +/* $Id: php_zip.c,v 1.63 2008/10/23 21:18:13 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -88,80 +88,153 @@ RETURN_FALSE; \ } \ RETURN_TRUE; +/* }}} */ + +#if (PHP_MAJOR_VERSION 6) +# define add_ascii_assoc_string add_assoc_string +# define add_ascii_assoc_long add_assoc_long +#endif + +/* Flatten a path by making a relative path (to .)*/ +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])) { + return path + 1; + } + + if (path_len 1 || path == NULL) { + return NULL; + } + + i = path_len; + + while (1) { + while (i 0 !IS_SLASH(path[i])) { + i--; + } + + if (!i) { + return path; + } + + if (i = 2 (path[i -1] == '.' || path[i -1] == ':')) { + /* i is the position of . or :, add 1 for / */ + path_begin = path + i + 1; + break; + } + i--; + } + return path_begin; +} /* }}} */ +#ifdef ZEND_ENGINE_2_1 /* {{{ php_zip_extract_file */ -/* TODO: Simplify it */ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int file_len TSRMLS_DC) { php_stream_statbuf ssb; struct zip_file *zf; struct zip_stat sb; char b[8192]; - int n, len, ret; - php_stream *stream; - char *fullpath; char *file_dirname_fullpath; char file_dirname[MAXPATHLEN]; size_t dir_len; - char *file_basename; size_t file_basename_len; int is_dir_only = 0; + char *path_cleaned; + size_t path_cleaned_len; + cwd_state new_state; + + new_state.cwd = (char*)malloc(1); + new_state.cwd[0] = '\0'; + new_state.cwd_length = 0; + + /* Clean/normlize the path and then transform any path (absolute or relative) +to a path relative to cwd (../../mydir/foo.txt mydir/foo.txt) +*/ + virtual_file_ex(new_state, file, NULL, CWD_EXPAND); + path_cleaned = php_zip_make_relative_path(new_state.cwd, new_state.cwd_length); + path_cleaned_len = strlen(path_cleaned); - if (file_len = MAXPATHLEN || zip_stat(za, file, 0, sb) != 0) { + if (path_cleaned_len = MAXPATHLEN || zip_stat(za, file, 0, sb) != 0) { return 0; } + /* it is a directory only, see #40228 */ - if (file_len 1 file[file_len - 1] == '/') { + if (path_cleaned_len 1 IS_SLASH(path_cleaned[path_cleaned_len - 1])) { len = spprintf(file_dirname_fullpath, 0, %s/%s, dest, file); is_dir_only = 1; } else { - memcpy(file_dirname, file, file_len); - dir_len = php_dirname(file_dirname, file_len); + memcpy(file_dirname, path_cleaned, path_cleaned_len); + dir_len = php_dirname(file_dirname, path_cleaned_len); - if (dir_len 0) { - len = spprintf(file_dirname_fullpath, 0, %s/%s, dest, file_dirname); - } else { + if (dir_len = 0 || (dir_len == 1 file_dirname[0] == '.')) { len = spprintf(file_dirname_fullpath, 0, %s, dest); + } else { + len = spprintf(file_dirname_fullpath, 0, %s/%s, dest, file_dirname); } - php_basename(file, file_len, NULL, 0, file_basename, (unsigned int *)file_basename_len TSRMLS_CC); + php_basename(path_cleaned, path_cleaned_len, NULL, 0, file_basename, (unsigned int *)file_basename_len TSRMLS_CC); if (OPENBASEDIR_CHECKPATH(file_dirname_fullpath)) { efree(file_dirname_fullpath); efree(file_basename); + free(new_state.cwd); return 0; } } + /* let see if the path already exists */ if (php_stream_stat_path(file_dirname_fullpath, ssb) 0) {
[PHP-CVS] cvs: php-src /ext/zip php_zip.c
tony2001Tue Jul 1 08:21:57 2008 UTC Modified files: /php-src/ext/zipphp_zip.c Log: fix typo http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.57r2=1.58diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.57 php-src/ext/zip/php_zip.c:1.58 --- php-src/ext/zip/php_zip.c:1.57 Fri Jan 18 01:24:29 2008 +++ php-src/ext/zip/php_zip.c Tue Jul 1 08:21:57 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.57 2008/01/18 01:24:29 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.58 2008/07/01 08:21:57 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1851,7 +1851,7 @@ RETURN_FALSE; } - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z|z, pathto_zval, pathto_len, zval_files) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z|z, pathto_zval, zval_files) == FAILURE) { return; } @@ -2205,7 +2205,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.57 2008/01/18 01:24:29 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.58 2008/07/01 08:21:57 tony2001 Exp $); php_info_print_table_row(2, Zip version, PHP_ZIP_VERSION_STRING); php_info_print_table_row(2, Libzip version, 0.8.0); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/zip php_zip.c php_zip.h
pajoye Fri Jan 18 01:24:29 2008 UTC Modified files: /php-src/ext/zipphp_zip.c php_zip.h Log: - MFB: reflect the correct version http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.56r2=1.57diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.56 php-src/ext/zip/php_zip.c:1.57 --- php-src/ext/zip/php_zip.c:1.56 Fri Jan 18 00:33:15 2008 +++ php-src/ext/zip/php_zip.c Fri Jan 18 01:24:29 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.56 2008/01/18 00:33:15 cellog Exp $ */ +/* $Id: php_zip.c,v 1.57 2008/01/18 01:24:29 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -2205,9 +2205,9 @@ 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.56 2008/01/18 00:33:15 cellog 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_row(2, Extension Version,$Id: php_zip.c,v 1.57 2008/01/18 01:24:29 pajoye Exp $); + php_info_print_table_row(2, Zip version, PHP_ZIP_VERSION_STRING); + php_info_print_table_row(2, Libzip version, 0.8.0); php_info_print_table_end(); } http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.h?r1=1.16r2=1.17diff_format=u Index: php-src/ext/zip/php_zip.h diff -u php-src/ext/zip/php_zip.h:1.16 php-src/ext/zip/php_zip.h:1.17 --- php-src/ext/zip/php_zip.h:1.16 Mon Dec 31 07:12:17 2007 +++ php-src/ext/zip/php_zip.h Fri Jan 18 01:24:29 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.h,v 1.16 2007/12/31 07:12:17 sebastian Exp $ */ +/* $Id: php_zip.h,v 1.17 2008/01/18 01:24:29 pajoye Exp $ */ #ifndef PHP_ZIP_H #define PHP_ZIP_H @@ -30,6 +30,8 @@ #include lib/zip.h +#define PHP_ZIP_VERSION_STRING 1.8.11 + /* {{{ OPENBASEDIR_CHECKPATH(filename) */ #if (PHP_MAJOR_VERSION 6) #define OPENBASEDIR_CHECKPATH(filename) \ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/zip php_zip.c
tony2001Mon Jan 14 08:17:55 2008 UTC Modified files: /php-src/ext/zipphp_zip.c Log: fix build http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.54r2=1.55diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.54 php-src/ext/zip/php_zip.c:1.55 --- php-src/ext/zip/php_zip.c:1.54 Sun Jan 13 06:24:27 2008 +++ php-src/ext/zip/php_zip.c Mon Jan 14 08:17:55 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.54 2008/01/13 06:24:27 cellog Exp $ */ +/* $Id: php_zip.c,v 1.55 2008/01/14 08:17:55 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -943,7 +943,7 @@ /* {{{ proto string zip_entry_compressionmethod(resource zip_entry) U Return a string containing the compression method used on a particular entry */ -static PHP_FUNCTION(zif_zip_entry_compressionmethod) +static PHP_NAMED_FUNCTION(zif_zip_entry_compressionmethod) { php_zip_entry_get_info(INTERNAL_FUNCTION_PARAM_PASSTHRU, 3); } @@ -2205,7 +2205,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.54 2008/01/13 06:24:27 cellog Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.55 2008/01/14 08:17:55 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 /ext/zip php_zip.c /ext/zip/lib zip.h zip_alias.h zipint.h zipint_alias.h
cellog Sun Jan 13 06:01:59 2008 UTC Added files: /php-src/ext/zip/libzip_alias.h zipint_alias.h Modified files: /php-src/ext/zipphp_zip.c /php-src/ext/zip/libzip.h zipint.h Log: MFPECL: alias all zip identifiers to avoid potential name conflicts with other apache libs that may export zip symbols http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.52r2=1.53diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.52 php-src/ext/zip/php_zip.c:1.53 --- php-src/ext/zip/php_zip.c:1.52 Mon Dec 31 07:12:17 2007 +++ php-src/ext/zip/php_zip.c Sun Jan 13 06:01:58 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.52 2007/12/31 07:12:17 sebastian Exp $ */ +/* $Id: php_zip.c,v 1.53 2008/01/13 06:01:58 cellog Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -31,16 +31,17 @@ #include lib/zip.h #include lib/zipint.h -static PHP_FUNCTION(zip_open); -static PHP_FUNCTION(zip_read); -static PHP_FUNCTION(zip_close); -static PHP_FUNCTION(zip_entry_read); -static PHP_FUNCTION(zip_entry_filesize); -static PHP_FUNCTION(zip_entry_name); -static PHP_FUNCTION(zip_entry_compressedsize); -static PHP_FUNCTION(zip_entry_compressionmethod); -static PHP_FUNCTION(zip_entry_open); -static PHP_FUNCTION(zip_entry_close); +/* 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); +static PHP_NAMED_FUNCTION(zif_zip_close); +static PHP_NAMED_FUNCTION(zif_zip_entry_read); +static PHP_NAMED_FUNCTION(zif_zip_entry_filesize); +static PHP_NAMED_FUNCTION(zif_zip_entry_name); +static PHP_NAMED_FUNCTION(zif_zip_entry_compressedsize); +static PHP_NAMED_FUNCTION(zif_zip_entry_compressionmethod); +static PHP_NAMED_FUNCTION(zif_zip_entry_open); +static PHP_NAMED_FUNCTION(zif_zip_entry_close); /* {{{ Resource le */ static int le_zip_dir; @@ -273,9 +274,9 @@ /* {{{ zend_function_entry */ static const zend_function_entry zip_functions[] = { - PHP_FE(zip_open,NULL) - PHP_FE(zip_close, NULL) - PHP_FE(zip_read,NULL) + PHP_RAW_NAMED_FE(zip_open, zif_zip_open, NULL) + PHP_RAW_NAMED_FE(zip_close, zif_zip_close, NULL) + PHP_RAW_NAMED_FE(zip_read, zif_zip_read, NULL) PHP_FE(zip_entry_open, NULL) PHP_FE(zip_entry_close, NULL) PHP_FE(zip_entry_read, NULL) @@ -634,6 +635,8 @@ /* }}}*/ +/* reset macro */ +#undef zip /* {{{ function prototypes */ static PHP_MINIT_FUNCTION(zip); static PHP_MSHUTDOWN_FUNCTION(zip); @@ -659,10 +662,12 @@ #ifdef COMPILE_DL_ZIP ZEND_GET_MODULE(zip) #endif +/* set macro */ +#define zip php_ziplib__zip /* {{{ proto resource zip_open(string filename) U Create new zip using source uri for output */ -static PHP_FUNCTION(zip_open) +static PHP_NAMED_FUNCTION(zif_zip_open) { zval **filename_zval; char *filename; @@ -708,7 +713,7 @@ /* {{{ proto void zip_close(resource zip) U Close a Zip archive */ -static PHP_FUNCTION(zip_close) +static PHP_NAMED_FUNCTION(zif_zip_close) { zval * zip; zip_rsrc *z_rsrc = NULL; @@ -725,7 +730,7 @@ /* {{{ proto resource zip_read(resource zip) U Returns the next file in the archive */ -static PHP_FUNCTION(zip_read) +static PHP_NAMED_FUNCTION(zif_zip_read) { zval *zip_dp; zip_read_rsrc *zr_rsrc; @@ -769,7 +774,7 @@ /* {{{ proto bool zip_entry_open(resource zip_dp, resource zip_entry [, string mode]) U Open a Zip File, pointed by the resource entry */ /* Dummy function to follow the old API */ -static PHP_FUNCTION(zip_entry_open) +static PHP_NAMED_FUNCTION(zif_zip_entry_open) { zval * zip; zval * zip_entry; @@ -797,7 +802,7 @@ /* {{{ proto void zip_entry_close(resource zip_ent) U Close a zip entry */ /* another dummy function to fit in the old api*/ -static PHP_FUNCTION(zip_entry_close) +static PHP_NAMED_FUNCTION(zif_zip_entry_close) { zval * zip_entry; zip_read_rsrc * zr_rsrc; @@ -814,7 +819,7 @@ /* {{{ proto mixed zip_entry_read(resource zip_entry [, int len]) U Read from an open directory entry */ -static PHP_FUNCTION(zip_entry_read) +static PHP_NAMED_FUNCTION(zif_zip_entry_read) { zval * zip_entry; long len = 0; @@ -914,7 +919,7 @@ /* {{{ proto string zip_entry_name(resource zip_entry) U Return the name given a ZZip entry */ -static PHP_FUNCTION(zip_entry_name) +static PHP_NAMED_FUNCTION(zif_zip_entry_name) { php_zip_entry_get_info(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); } @@ -922,7 +927,7 @@ /* {{{ proto int zip_entry_compressedsize(resource zip_entry) U Return the compressed size of a ZZip entry */ -static PHP_FUNCTION(zip_entry_compressedsize) +static
[PHP-CVS] cvs: php-src /ext/zip php_zip.c /ext/zip/lib zipint_alias.h
cellog Sun Jan 13 06:24:27 2008 UTC Modified files: /php-src/ext/zipphp_zip.c /php-src/ext/zip/libzipint_alias.h Log: MFB: a few fixes: overwrote all my careful work in zipint_alias.h with zipint.h, so had to restore that. PHP_RAW_NAMED_FE() won't work, have to use ZEND_RAW_FENTRY http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.53r2=1.54diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.53 php-src/ext/zip/php_zip.c:1.54 --- php-src/ext/zip/php_zip.c:1.53 Sun Jan 13 06:01:58 2008 +++ php-src/ext/zip/php_zip.c Sun Jan 13 06:24:27 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.53 2008/01/13 06:01:58 cellog Exp $ */ +/* $Id: php_zip.c,v 1.54 2008/01/13 06:24:27 cellog Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -274,9 +274,9 @@ /* {{{ zend_function_entry */ static const zend_function_entry zip_functions[] = { - PHP_RAW_NAMED_FE(zip_open, zif_zip_open, NULL) - PHP_RAW_NAMED_FE(zip_close, zif_zip_close, NULL) - PHP_RAW_NAMED_FE(zip_read, zif_zip_read, NULL) + ZEND_RAW_FENTRY(zip_open, zif_zip_open, NULL, 0) + ZEND_RAW_FENTRY(zip_close, zif_zip_close, NULL, 0) + ZEND_RAW_FENTRY(zip_read, zif_zip_read, NULL, 0) PHP_FE(zip_entry_open, NULL) PHP_FE(zip_entry_close, NULL) PHP_FE(zip_entry_read, NULL) @@ -2205,7 +2205,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.53 2008/01/13 06:01:58 cellog Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.54 2008/01/13 06:24:27 cellog 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/zipint_alias.h?r1=1.1r2=1.2diff_format=u Index: php-src/ext/zip/lib/zipint_alias.h diff -u php-src/ext/zip/lib/zipint_alias.h:1.1 php-src/ext/zip/lib/zipint_alias.h:1.2 --- php-src/ext/zip/lib/zipint_alias.h:1.1 Sun Jan 13 06:01:59 2008 +++ php-src/ext/zip/lib/zipint_alias.h Sun Jan 13 06:24:27 2008 @@ -1,45 +1,49 @@ -#define zip_source_cmd php_ziplib__zip_source_cmd -#define zip_source_callback php_ziplib__zip_source_callback -#define zip_stat php_ziplib__zip_stat -#define zip php_ziplib__zip -#define zip_file php_ziplib__zip_file +/* state of change of a file in zip archive */ +#define zip_state php_ziplib__zip_state +#define zip_error php_ziplib__zip_error +#define zip_dirent php_ziplib__zip_dirent +#define zip_cdir php_ziplib__zip_cdir #define zip_source php_ziplib__zip_source -#define zip_add php_ziplib__zip_add -#define zip_add_dir php_ziplib__zip_add_dir -#define zip_close php_ziplib__zip_close -#define zip_delete php_ziplib__zip_delete -#define zip_error_clear php_ziplib__zip_error_clear -#define zip_error_get php_ziplib__zip_error_get -#define zip_error_get_sys_type php_ziplib__zip_error_get_sys_type -#define zip_error_to_str php_ziplib__zip_error_to_str -#define zip_fclose php_ziplib__zip_fclose -#define zip_file_error_clear php_ziplib__zip_fille_error_clear -#define zip_file_error_get php_ziplib__zip_file_error_get -#define zip_file_strerror php_ziplib__zip_file_strerror -#define zip_fopen php_ziplib__zip_fopen -#define zip_fopen_index php_ziplib__zip_fopen_index -#define zip_fread php_ziplib__zip_fread -#define zip_get_archive_comment php_ziplib__zip_get_archive_comment -#define zip_get_file_comment php_ziplib__zip_get_file_comment -#define zip_get_name php_ziplib__zip_get_name -#define zip_get_num_files php_ziplib__zip_get_num_files -#define zip_name_locate php_ziplib__zip_name_locate -#define zip_open php_ziplib__zip_open -#define zip_rename php_ziplib__zip_rename -#define zip_replace php_ziplib__zip_replace -#define zip_set_archive_comment php_ziplib__zip_set_archive_comment -#define zip_set_file_comment php_ziplib__zip_set_file_comment -#define zip_source_buffer php_ziplib__zip_source_buffer -#define zip_source_file php_ziplib__zip_source_file -#define zip_source_filep php_ziplib__zip_source_filep -#define zip_source_free php_ziplib__zip_source_free -#define zip_source_function php_ziplib__zip_source_function -#define zip_source_zip php_ziplib__zip_source_zip -#define zip_stat php_ziplib__zip_stat -#define zip_stat_index php_ziplib__zip_stat_index -#define zip_stat_init php_ziplib__zip_stat_init -#define zip_strerror php_ziplib__zip_strerror -#define zip_unchange php_ziplib__zip_unchange -#define zip_unchange_all php_ziplib__zip_unchange_all -#define zip_unchange_archive php_ziplib__zip_unchange_archive +#define zip_entry php_ziplib__zip_entry + +#define _zip_err_str php_ziplib___zip_err_str +#define _zip_nerr_str php_ziplib___zip_nerr_str +#define _zip_err_type php_ziplib___zip_err_type + +#define
[PHP-CVS] cvs: php-src /ext/zip php_zip.c
bjori Sat Dec 15 12:57:05 2007 UTC Modified files: /php-src/ext/zipphp_zip.c Log: MFB: Fix protos http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.50r2=1.51diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.50 php-src/ext/zip/php_zip.c:1.51 --- php-src/ext/zip/php_zip.c:1.50 Sun Oct 7 05:15:07 2007 +++ php-src/ext/zip/php_zip.c Sat Dec 15 12:57:05 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.50 2007/10/07 05:15:07 davidw Exp $ */ +/* $Id: php_zip.c,v 1.51 2007/12/15 12:57:05 bjori Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -944,7 +944,7 @@ } /* }}} */ -/* {{{ proto mixed open(string source [, int flags]) U +/* {{{ proto mixed ZipArchive::open(string source [, int flags]) U Create new zip using source uri for output, return TRUE on success or the error code */ static ZIPARCHIVE_METHOD(open) { @@ -1008,7 +1008,7 @@ } /* }}} */ -/* {{{ proto bool close() U +/* {{{ proto bool ZipArchive::close() U close the zip archive */ static ZIPARCHIVE_METHOD(close) { @@ -1037,7 +1037,7 @@ } /* }}} */ -/* {{{ proto bool createEmptyDir(string dirname) U +/* {{{ proto bool ZipArchive::createEmptyDir(string dirname) U Returns the index of the entry named filename in the archive */ static ZIPARCHIVE_METHOD(addEmptyDir) { @@ -1096,7 +1096,7 @@ } /* }}} */ -/* {{{ proto bool addFile(string filepath[, string entryname[, int start [, int length]]]) U +/* {{{ proto bool ZipArchive::addFile(string filepath[, string entryname[, int start [, int length]]]) U Add a file in a Zip archive using its path and the name to use. */ static ZIPARCHIVE_METHOD(addFile) { @@ -1201,7 +1201,7 @@ } /* }}} */ -/* {{{ proto bool addFromString(string name, string content) U +/* {{{ proto bool ZipArchive::addFromString(string name, string content) U Add a file using content and the entry name */ static ZIPARCHIVE_METHOD(addFromString) { @@ -1267,7 +1267,7 @@ } /* }}} */ -/* {{{ proto array statName(string filename[, int flags]) U +/* {{{ proto array ZipArchive::statName(string filename[, int flags]) U Returns the information about a the zip entry filename */ static ZIPARCHIVE_METHOD(statName) { @@ -1301,7 +1301,7 @@ } /* }}} */ -/* {{{ proto resource statIndex(int index[, int flags]) U +/* {{{ proto resource ZipArchive::statIndex(int index[, int flags]) U Returns the zip entry informations using its index */ static ZIPARCHIVE_METHOD(statIndex) { @@ -1329,7 +1329,7 @@ } /* }}} */ -/* {{{ proto int locateName(string filename[, int flags]) U +/* {{{ proto int ZipArchive::locateName(string filename[, int flags]) U Returns the index of the entry named filename in the archive */ static ZIPARCHIVE_METHOD(locateName) { @@ -1369,7 +1369,7 @@ } /* }}} */ -/* {{{ proto string getNameIndex(int index [, int flags]) U +/* {{{ proto string ZipArchive::getNameIndex(int index [, int flags]) U Returns the name of the file at position index */ static ZIPARCHIVE_METHOD(getNameIndex) { @@ -1399,7 +1399,7 @@ } /* }}} */ -/* {{{ proto bool setArchiveComment(string name, string comment) U +/* {{{ proto bool ZipArchive::setArchiveComment(string name, string comment) U Set or remove (NULL/'') the comment of the archive */ static ZIPARCHIVE_METHOD(setArchiveComment) { @@ -1425,7 +1425,7 @@ } /* }}} */ -/* {{{ proto string getArchiveComment() U +/* {{{ proto string ZipArchive::getArchiveComment() U Returns the comment of an entry using its index */ static ZIPARCHIVE_METHOD(getArchiveComment) { @@ -1450,7 +1450,7 @@ } /* }}} */ -/* {{{ proto bool setCommentName(string name, string comment) U +/* {{{ proto bool ZipArchive::setCommentName(string name, string comment) U Set or remove (NULL/'') the comment of an entry using its Name */ static ZIPARCHIVE_METHOD(setCommentName) { @@ -1484,7 +1484,7 @@ } /* }}} */ -/* {{{ proto bool setCommentIndex(int index, string comment) U +/* {{{ proto bool ZipArchive::setCommentIndex(int index, string comment) U Set or remove (NULL/'') the comment of an entry using its index */ static ZIPARCHIVE_METHOD(setCommentIndex) { @@ -1511,7 +1511,7 @@ } /* }}} */ -/* {{{ proto string getCommentName(string name) U +/* {{{ proto string ZipArchive::getCommentName(string name) U Returns the comment of an entry using its name */ static ZIPARCHIVE_METHOD(getCommentName) { @@ -1549,7 +1549,7 @@ } /* }}} */ -/* {{{ proto string getCommentIndex(int index) U +/* {{{ proto string ZipArchive::getCommentIndex(int index) U Returns the comment of an entry using its index */ static ZIPARCHIVE_METHOD(getCommentIndex) { @@ -1577,7 +1577,7 @@ } /* }}} */ -/* {{{ proto bool deleteIndex(int index) U +/* {{{ proto bool ZipArchive::deleteIndex(int index) U Delete a file using its index */ static ZIPARCHIVE_METHOD(deleteIndex) { @@ -1607,7 +1607,7 @@ } /* }}} */ -/* {{{ proto
[PHP-CVS] cvs: php-src /ext/zip php_zip.c /ext/zip/tests oo_properties.phpt
bjori Mon Aug 6 21:59:11 2007 UTC Added files: /php-src/ext/zip/tests oo_properties.phpt Modified files: /php-src/ext/zipphp_zip.c Log: - Fix isset/empty($ZipArchive-property) - Add test http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.47r2=1.48diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.47 php-src/ext/zip/php_zip.c:1.48 --- php-src/ext/zip/php_zip.c:1.47 Mon Jun 4 06:38:08 2007 +++ php-src/ext/zip/php_zip.c Mon Aug 6 21:59:10 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.47 2007/06/04 06:38:08 tony2001 Exp $ */ +/* $Id: php_zip.c,v 1.48 2007/08/06 21:59:10 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; @@ -2059,6 +2108,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; @@ -2145,7 +2195,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.47 2007/06/04 06:38:08 tony2001 Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.48 2007/08/06 21:59:10 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 isset(): 1 zip-numFiles (4): empty(): 0
[PHP-CVS] cvs: php-src /ext/zip php_zip.c
tony2001Mon Jun 4 06:38:09 2007 UTC Modified files: /php-src/ext/zipphp_zip.c Log: fix ws http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.46r2=1.47diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.46 php-src/ext/zip/php_zip.c:1.47 --- php-src/ext/zip/php_zip.c:1.46 Sun Jun 3 21:35:39 2007 +++ php-src/ext/zip/php_zip.c Mon Jun 4 06:38:08 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.46 2007/06/03 21:35:39 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.47 2007/06/04 06:38:08 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1015,12 +1015,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; } @@ -2145,7 +2145,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.46 2007/06/03 21:35:39 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.47 2007/06/04 06:38:08 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 /ext/zip php_zip.c /ext/zip/tests bug11216.phpt
pajoye Sun Jun 3 21:30:12 2007 UTC Modified files: /php-src/ext/zipphp_zip.c /php-src/ext/zip/tests bug11216.phpt Log: - MFB: PECL #11216, addEmptyDir crashes if the directory already exists http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.44r2=1.45diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.44 php-src/ext/zip/php_zip.c:1.45 --- php-src/ext/zip/php_zip.c:1.44 Sat May 19 22:26:32 2007 +++ php-src/ext/zip/php_zip.c Sun Jun 3 21:30:12 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.44 2007/05/19 22:26:32 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.45 2007/06/03 21:30:12 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -996,6 +996,9 @@ zval *this = getThis(); char *dirname; int dirname_len; + int idx; + struct zip_stat sb; + char *s; if (!this) { RETURN_FALSE; @@ -1007,14 +1010,39 @@ dirname, dirname_len, UG(ascii_conv)) == FAILURE) { return; } + if (dirname_len1) { RETURN_FALSE; } - if (zip_add_dir(intern, (const char *)dirname) 0) { - RETURN_FALSE; +if (dirname[dirname_len-1] != '/') { + s=(char *)emalloc(dirname_len+2); + strcpy(s, dirname); + s[dirname_len] = '/'; + s[dirname_len+1] = '\0'; +} else { + s = dirname; + } + + idx = zip_stat(intern, s, 0, sb); + if (idx = 0) { + RETVAL_FALSE; + } else { + /* reset the error */ + if (intern-error.str) { + _zip_error_fini(intern-error); + } + _zip_error_init(intern-error); + + if (zip_add_dir(intern, (const char *)s) == -1) { + RETVAL_FALSE; + } + RETVAL_TRUE; + } + + if (s != dirname) { + efree(s); } - RETURN_TRUE; } /* }}} */ @@ -2116,7 +2144,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.44 2007/05/19 22:26:32 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.45 2007/06/03 21:30:12 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/bug11216.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/zip/tests/bug11216.phpt diff -u /dev/null php-src/ext/zip/tests/bug11216.phpt:1.2 --- /dev/null Sun Jun 3 21:30:12 2007 +++ php-src/ext/zip/tests/bug11216.phpt Sun Jun 3 21:30:12 2007 @@ -0,0 +1,28 @@ +--TEST-- +Bug #11216 (::addEmptyDir() crashes when the directory already exists) +--SKIPIF-- +?php +/* $Id: bug11216.phpt,v 1.2 2007/06/03 21:30:12 pajoye Exp $ */ +if(!extension_loaded('zip')) die('skip'); + ? +--FILE-- +?php +$archive = new ZipArchive(); +$archive-open('__test.zip', ZIPARCHIVE::CREATE); +var_dump($archive-addEmptyDir('test')); +print_r($archive); +var_dump($archive-addEmptyDir('test')); +$archive-close(); +unlink('__test.zip'); +? +--EXPECT-- +bool(true) +ZipArchive Object +( +[status] = 0 +[statusSys] = 0 +[numFiles] = 1 +[filename] = +[comment] = +) +bool(false) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/zip php_zip.c
pajoye Sun Jun 3 21:35:40 2007 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - MFB: fix logic http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.45r2=1.46diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.45 php-src/ext/zip/php_zip.c:1.46 --- php-src/ext/zip/php_zip.c:1.45 Sun Jun 3 21:30:12 2007 +++ php-src/ext/zip/php_zip.c Sun Jun 3 21:35:39 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.45 2007/06/03 21:30:12 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.46 2007/06/03 21:35:39 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1036,8 +1036,9 @@ if (zip_add_dir(intern, (const char *)s) == -1) { RETVAL_FALSE; + } else { + RETVAL_TRUE; } - RETVAL_TRUE; } if (s != dirname) { @@ -2144,7 +2145,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.45 2007/06/03 21:30:12 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.46 2007/06/03 21:35:39 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 /ext/zip php_zip.c
pajoye Sat May 19 22:26:32 2007 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - MFB: - Fixed a possible crash in the event directory cannot be created, due to a double free. (Ilia) - Use the same tests for zip_stat http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.43r2=1.44diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.43 php-src/ext/zip/php_zip.c:1.44 --- php-src/ext/zip/php_zip.c:1.43 Wed Mar 14 16:34:56 2007 +++ php-src/ext/zip/php_zip.c Sat May 19 22:26:32 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.43 2007/03/14 16:34:56 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.44 2007/05/19 22:26:32 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) == -1) { \ 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; } @@ -1200,6 +1200,8 @@ long flags = 0; struct zip_stat sb; + int res = 0; + if (!this) { RETURN_FALSE; } @@ -1210,6 +1212,10 @@ name, name_len, UG(ascii_conv), flags) == FAILURE) { return; } + res =zip_stat(intern, name, flags, sb); + if (res == -1) { + RETURN_FALSE; + } PHP_ZIP_STAT_PATH(intern, name, name_len, flags, sb); @@ -1770,14 +1776,13 @@ RETURN_FALSE; } - 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; } } @@ -1800,7 +1805,7 @@ RETURN_FALSE; } - if (!php_zip_extract_file(intern, pathto, file, file_len TSRMLS_CC)) { + if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files) TSRMLS_CC)) { efree(file); RETURN_FALSE; } @@ -1831,7 +1836,6 @@ } if (!php_zip_extract_file(intern, pathto, file, file_len TSRMLS_CC)) { - efree(file); RETURN_FALSE; } break; @@ -1854,7 +1858,7 @@ } for (i = 0; i filecount; i++) { -file = (char*)zip_get_name(intern, i, ZIP_FL_UNCHANGED); +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; } @@ -1969,7 +1973,7 @@ return; } - if (zip_stat(intern, filename, 0, sb)) { + if (zip_stat(intern, filename, 0, sb) != 0) { RETURN_FALSE; } @@ -2112,7 +2116,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.43 2007/03/14 16:34:56 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.44 2007/05/19 22:26:32 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 /ext/zip php_zip.c php_zip.h zip_stream.c
pajoye Wed Mar 14 11:22:13 2007 UTC Modified files: /php-src/ext/zipphp_zip.h php_zip.c zip_stream.c Log: - MFB: - rename SAFEMODE_CHECKFILE to OPENBASEDIR_CHECKPATH (can be used without confusing in head without confusion) - Add safemode and open basedir checks in zip:// wrapper (revert Ilia's patch). Bug found by Stefan Esser in his MOPB-20-2007 http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.h?r1=1.14r2=1.15diff_format=u Index: php-src/ext/zip/php_zip.h diff -u php-src/ext/zip/php_zip.h:1.14 php-src/ext/zip/php_zip.h:1.15 --- php-src/ext/zip/php_zip.h:1.14 Mon Jan 1 09:29:34 2007 +++ php-src/ext/zip/php_zip.h Wed Mar 14 11:22:13 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.h,v 1.14 2007/01/01 09:29:34 sebastian Exp $ */ +/* $Id: php_zip.h,v 1.15 2007/03/14 11:22:13 pajoye Exp $ */ #ifndef PHP_ZIP_H #define PHP_ZIP_H @@ -30,6 +30,16 @@ #include lib/zip.h +/* {{{ OPENBASEDIR_CHECKPATH(filename) */ +#if (PHP_MAJOR_VERSION 6) +#define OPENBASEDIR_CHECKPATH(filename) \ + (PG(safe_mode) (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC) +#else +#define OPENBASEDIR_CHECKPATH(filename) \ + php_check_open_basedir(filename TSRMLS_CC) +#endif +/* }}} */ + typedef struct _ze_zip_rsrc { struct zip *za; int index_current; http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.38r2=1.39diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.38 php-src/ext/zip/php_zip.c:1.39 --- php-src/ext/zip/php_zip.c:1.38 Mon Jan 29 16:01:55 2007 +++ php-src/ext/zip/php_zip.c Wed Mar 14 11:22:13 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.38 2007/01/29 16:01:55 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.39 2007/03/14 11:22:13 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -122,6 +122,11 @@ } php_basename(file, file_len, NULL, 0, file_basename, (unsigned int *)file_basename_len TSRMLS_CC); + if (OPENBASEDIR_CHECKPATH(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) { @@ -149,6 +154,16 @@ return 0; } + /* check again the full path, not sure if it +* is required, does a file can have a different +* safemode status as its parent folder? +*/ + if (OPENBASEDIR_CHECKPATH(fullpath)) { + efree(file_dirname_fullpath); + efree(file_basename); + return 0; + } + zf = zip_fopen(za, file, 0); if (zf == NULL) { efree(fullpath); @@ -609,6 +624,9 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z, filename_zval) == FAILURE) { return; } + if (OPENBASEDIR_CHECKPATH(filename)) { + RETURN_FALSE; + } if (FAILURE == php_stream_path_param_encode(filename_zval, filename, filename_len, REPORT_ERRORS, FG(default_context))) { RETURN_FALSE; @@ -2083,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.38 2007/01/29 16:01:55 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.39 2007/03/14 11:22:13 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/zip_stream.c?r1=1.5r2=1.6diff_format=u Index: php-src/ext/zip/zip_stream.c diff -u php-src/ext/zip/zip_stream.c:1.5 php-src/ext/zip/zip_stream.c:1.6 --- php-src/ext/zip/zip_stream.c:1.5Mon Jan 1 09:29:34 2007 +++ php-src/ext/zip/zip_stream.cWed Mar 14 11:22:13 2007 @@ -1,4 +1,4 @@ -/* $Id: zip_stream.c,v 1.5 2007/01/01 09:29:34 sebastian Exp $ */ +/* $Id: zip_stream.c,v 1.6 2007/03/14 11:22:13 pajoye Exp $ */ #ifdef HAVE_CONFIG_H # include config.h #endif @@ -12,6 +12,7 @@ #include ext/standard/file.h #include ext/standard/php_string.h #include fopen_wrappers.h +#include php_zip.h #include ext/standard/url.h @@ -112,6 +113,10 @@ } if (filename) { + if (OPENBASEDIR_CHECKPATH(filename)) { + return NULL; + } + /* duplicate to make the stream za independent (esp. for MSHUTDOWN) */ stream_za = zip_open(filename, ZIP_CREATE, err); if (!stream_za) { @@ -189,6 +194,11 @@
[PHP-CVS] cvs: php-src /ext/zip php_zip.c
pajoye Wed Mar 14 11:37:35 2007 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - MFB: free rsrc on error in zip_read (old API) http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.40r2=1.41diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.40 php-src/ext/zip/php_zip.c:1.41 --- php-src/ext/zip/php_zip.c:1.40 Wed Mar 14 11:25:20 2007 +++ php-src/ext/zip/php_zip.c Wed Mar 14 11:37:35 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.40 2007/03/14 11:25:20 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.41 2007/03/14 11:37:35 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -706,6 +706,7 @@ rsrc_int-index_current++; ZEND_REGISTER_RESOURCE(return_value, zr_rsrc, le_zip_entry); } else { + efree(zr_rsrc); RETURN_FALSE; } @@ -2102,7 +2103,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.40 2007/03/14 11:25:20 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.41 2007/03/14 11:37:35 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 /ext/zip php_zip.c
pajoye Wed Mar 14 12:02:40 2007 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - add openbase_dir checks in ::open and addFile() http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.41r2=1.42diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.41 php-src/ext/zip/php_zip.c:1.42 --- php-src/ext/zip/php_zip.c:1.41 Wed Mar 14 11:37:35 2007 +++ php-src/ext/zip/php_zip.c Wed Mar 14 12:02:40 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.41 2007/03/14 11:37:35 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.42 2007/03/14 12:02:40 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -927,6 +927,10 @@ RETURN_FALSE; } + if (OPENBASEDIR_CHECKPATH(filename)) { + RETURN_FALSE; + } + if(!expand_filepath(filename, resolved_path TSRMLS_CC)) { RETURN_FALSE; } @@ -1067,6 +1071,10 @@ } } + if (OPENBASEDIR_CHECKPATH(filename)) { + RETURN_FALSE; + } + if(!expand_filepath(filename, resolved_path TSRMLS_CC)) { if (Z_TYPE_PP(filename_zval) == IS_UNICODE) { efree(entry_name); @@ -2103,7 +2111,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.41 2007/03/14 11:37:35 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.42 2007/03/14 12:02:40 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
Re: [PHP-CVS] cvs: php-src /ext/zip php_zip.c php_zip.h zip_stream.c
Revert? You just changed the code into a macro. Ilia -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/zip php_zip.c php_zip.h zip_stream.c
On 3/14/07, Ilia Alshanetsky [EMAIL PROTECTED] wrote: Revert? You just changed the code into a macro. It was already a macro, you should have used it. So yes, I revert yours, rename the macro to make its goal clearer and use it. --Pierre -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/zip php_zip.c
pajoye Wed Mar 14 16:34:56 2007 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - MFB: Fixed a possible memory leak on open_basedir validation (Ilia) http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.42r2=1.43diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.42 php-src/ext/zip/php_zip.c:1.43 --- php-src/ext/zip/php_zip.c:1.42 Wed Mar 14 12:02:40 2007 +++ php-src/ext/zip/php_zip.c Wed Mar 14 16:34:56 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.42 2007/03/14 12:02:40 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.43 2007/03/14 16:34:56 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -155,10 +155,11 @@ } /* check again the full path, not sure if it -* is required, does a file can have a different +* is required, can a file have a different * safemode status as its parent folder? */ if (OPENBASEDIR_CHECKPATH(fullpath)) { + efree(fullpath); efree(file_dirname_fullpath); efree(file_basename); return 0; @@ -2111,7 +2112,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.42 2007/03/14 12:02:40 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.43 2007/03/14 16:34:56 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 /ext/zip php_zip.c /ext/zip/tests bug40228.phpt bug40228.zip
pajoye Mon Jan 29 16:01:55 2007 UTC Modified files: /php-src/ext/zipphp_zip.c /php-src/ext/zip/tests bug40228.phpt bug40228.zip Log: - MFB: #40228, ZipArchive::extractTo does create empty directories recursively http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.37r2=1.38diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.37 php-src/ext/zip/php_zip.c:1.38 --- php-src/ext/zip/php_zip.c:1.37 Sat Jan 6 20:30:23 2007 +++ php-src/ext/zip/php_zip.c Mon Jan 29 16:01:55 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.37 2007/01/06 20:30:23 nlopess Exp $ */ +/* $Id: php_zip.c,v 1.38 2007/01/29 16:01:55 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -101,23 +101,28 @@ 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); - php_basename(file, file_len, NULL, 0, file_basename, file_basename_len TSRMLS_CC); + dir_len = php_dirname(file_dirname, file_len); + + if (dir_len 0) { + len = spprintf(file_dirname_fullpath, 0, %s/%s, dest, file_dirname); + } else { + len = spprintf(file_dirname_fullpath, 0, %s, dest); + } + php_basename(file, file_len, NULL, 0, file_basename, (unsigned int *)file_basename_len TSRMLS_CC); + } /* let see if the path already exists */ if (php_stream_stat_path(file_dirname_fullpath, ssb) 0) { ret = php_stream_mkdir(file_dirname_fullpath, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL); @@ -131,7 +136,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; } @@ -2076,7 +2083,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.37 2007/01/06 20:30:23 nlopess Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.38 2007/01/29 16:01:55 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?r1=1.1r2=1.2diff_format=u Index: php-src/ext/zip/tests/bug40228.phpt diff -u /dev/null php-src/ext/zip/tests/bug40228.phpt:1.2 --- /dev/null Mon Jan 29 16:01:55 2007 +++ php-src/ext/zip/tests/bug40228.phpt Mon Jan 29 16:01:55 2007 @@ -0,0 +1,23 @@ +--TEST-- +Bug #40228 (extractTo does not create recursive empty path) +--SKIPIF-- +?php if (!extension_loaded(zip)) print skip; ? +--FILE-- +?php +$dest = dirname(__FILE__); +$arc_name = $dest . /bug40228.zip; +$zip = new ZipArchive; +$zip-open($arc_name, ZIPARCHIVE::CREATE);; +$zip-extractTo($dest); +if (is_dir($dest . '/test/empty')) { + echo Ok\n; + rmdir($dest . '/test/empty'); + rmdir($dest . '/test'); +} else { + echo Failed.\n; +} +echo Done\n; +? +--EXPECT-- +Ok +Done http://cvs.php.net/viewvc.cgi/php-src/ext/zip/tests/bug40228.zip?r1=1.1r2=1.2diff_format=u Index: 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 /ext/zip php_zip.c
nlopess Sat Jan 6 20:30:23 2007 UTC Modified files: /php-src/ext/zipphp_zip.c Log: MFB http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.36r2=1.37diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.36 php-src/ext/zip/php_zip.c:1.37 --- php-src/ext/zip/php_zip.c:1.36 Mon Jan 1 09:29:34 2007 +++ php-src/ext/zip/php_zip.c Sat Jan 6 20:30:23 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.36 2007/01/01 09:29:34 sebastian Exp $ */ +/* $Id: php_zip.c,v 1.37 2007/01/06 20:30:23 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -531,7 +531,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; } @@ -904,17 +906,21 @@ 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; @@ -2070,7 +2076,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.36 2007/01/01 09:29:34 sebastian Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.37 2007/01/06 20:30:23 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 /ext/zip php_zip.c
tony2001Mon Dec 25 22:40:13 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: add missing space for \0 http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.34r2=1.35diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.34 php-src/ext/zip/php_zip.c:1.35 --- php-src/ext/zip/php_zip.c:1.34 Sat Dec 23 23:29:41 2006 +++ php-src/ext/zip/php_zip.c Mon Dec 25 22:40:13 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.34 2006/12/23 23:29:41 iliaa Exp $ */ +/* $Id: php_zip.c,v 1.35 2006/12/25 22:40:13 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1115,8 +1115,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); @@ -2070,7 +2070,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.34 2006/12/23 23:29:41 iliaa Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.35 2006/12/25 22:40:13 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 /ext/zip php_zip.c
pajoye Tue Dec 19 02:05:27 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - unicode support for the procedural API http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.32r2=1.33diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.32 php-src/ext/zip/php_zip.c:1.33 --- php-src/ext/zip/php_zip.c:1.32 Sun Dec 10 03:10:55 2006 +++ php-src/ext/zip/php_zip.c Tue Dec 19 02:05:27 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.32 2006/12/10 03:10:55 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.33 2006/12/19 02:05:27 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -587,19 +587,34 @@ ZEND_GET_MODULE(zip) #endif -/* {{{ proto resource zip_open(string filename) +/* {{{ proto resource zip_open(string filename) U Create new zip using source uri for output */ static PHP_FUNCTION(zip_open) { + zval **filename_zval; char *filename; int filename_len; + char resolved_path[MAXPATHLEN + 1]; zip_rsrc *rsrc_int; int err = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, filename, filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z, filename_zval) == FAILURE) { return; } + if (FAILURE == php_stream_path_param_encode(filename_zval, filename, filename_len, REPORT_ERRORS, FG(default_context))) { + RETURN_FALSE; + } + + if (filename_len == 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, Empty string as source); + RETURN_FALSE; + } + + if(!expand_filepath(filename, resolved_path TSRMLS_CC)) { + RETURN_FALSE; + } + rsrc_int = (zip_rsrc *)emalloc(sizeof(zip_rsrc)); rsrc_int-za = zip_open(filename, 0, err); @@ -615,7 +630,7 @@ } /* }}} */ -/* {{{ proto void zip_close(resource zip) +/* {{{ proto void zip_close(resource zip) U Close a Zip archive */ static PHP_FUNCTION(zip_close) { @@ -632,7 +647,7 @@ } /* }}} */ -/* {{{ proto resource zip_read(resource zip) +/* {{{ proto resource zip_read(resource zip) U Returns the next file in the archive */ static PHP_FUNCTION(zip_read) { @@ -657,7 +672,7 @@ if (ret != 0) { efree(zr_rsrc); - RETURN_LONG((long)ret); + RETURN_FALSE; } zr_rsrc-zf = zip_fopen_index(rsrc_int-za, rsrc_int-index_current, 0); @@ -674,7 +689,7 @@ } /* }}} */ -/* {{{ proto bool zip_entry_open(resource zip_dp, resource zip_entry [, string mode]) +/* {{{ proto bool zip_entry_open(resource zip_dp, resource zip_entry [, string mode]) U Open a Zip File, pointed by the resource entry */ /* Dummy function to follow the old API */ static PHP_FUNCTION(zip_entry_open) @@ -686,7 +701,8 @@ zip_read_rsrc * zr_rsrc; zip_rsrc *z_rsrc; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rr|s, zip, zip_entry, mode, mode_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rr|s, + zip, zip_entry, mode, mode_len, UG(ascii_conv)) == FAILURE) { return; } @@ -701,7 +717,7 @@ } /* }}} */ -/* {{{ proto void zip_entry_close(resource zip_ent) +/* {{{ proto void zip_entry_close(resource zip_ent) U Close a zip entry */ /* another dummy function to fit in the old api*/ static PHP_FUNCTION(zip_entry_close) @@ -719,7 +735,7 @@ } /* }}} */ -/* {{{ proto mixed zip_entry_read(resource zip_entry [, int len]) +/* {{{ proto mixed zip_entry_read(resource zip_entry [, int len]) U Read from an open directory entry */ static PHP_FUNCTION(zip_entry_read) { @@ -782,31 +798,31 @@ case 3: switch (zr_rsrc-sb.comp_method) { case 0: - RETURN_STRING(stored, 1); + RETURN_ASCII_STRING(stored, ZSTR_DUPLICATE); break; case 1: - RETURN_STRING(shrunk, 1); + RETURN_ASCII_STRING(shrunk, ZSTR_DUPLICATE); break; case 2: case 3: case 4: case 5: - RETURN_STRING(reduced, 1); + RETURN_ASCII_STRING(reduced, ZSTR_DUPLICATE); break; case 6: - RETURN_STRING(imploded, 1); + RETURN_ASCII_STRING(imploded,
[PHP-CVS] cvs: php-src /ext/zip php_zip.c
pajoye Sun Dec 10 03:10:55 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - MFB: addDir returns true http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.31r2=1.32diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.31 php-src/ext/zip/php_zip.c:1.32 --- php-src/ext/zip/php_zip.c:1.31 Sun Nov 12 00:31:37 2006 +++ php-src/ext/zip/php_zip.c Sun Dec 10 03:10:55 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.31 2006/11/12 00:31:37 nlopess Exp $ */ +/* $Id: php_zip.c,v 1.32 2006/12/10 03:10:55 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -961,6 +961,7 @@ if (zip_add_dir(intern, (const char *)dirname) 0) { RETURN_FALSE; } + RETURN_TRUE; } /* }}} */ @@ -2059,7 +2060,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.31 2006/11/12 00:31:37 nlopess Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.32 2006/12/10 03:10:55 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 /ext/zip php_zip.c /ext/zip/lib zip_fclose.c
nlopess Sat Nov 11 23:43:40 2006 UTC Modified files: /php-src/ext/zipphp_zip.c /php-src/ext/zip/libzip_fclose.c Log: MFB: fix leaks within zip entries in several tests http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.29r2=1.30diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.29 php-src/ext/zip/php_zip.c:1.30 --- php-src/ext/zip/php_zip.c:1.29 Thu Nov 9 16:18:28 2006 +++ php-src/ext/zip/php_zip.c Sat Nov 11 23:43:40 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.29 2006/11/09 16:18:28 nlopess Exp $ */ +/* $Id: php_zip.c,v 1.30 2006/11/11 23:43:40 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -531,6 +531,7 @@ if (zip_int) { if (zip_int-za) { zip_close(zip_int-za); + zip_int-za = NULL; } efree(rsrc-ptr); @@ -545,8 +546,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; + } } /* }}} */ @@ -2050,7 +2057,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.29 2006/11/09 16:18:28 nlopess Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.30 2006/11/11 23:43:40 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.2diff_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.2 --- 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:40 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 /ext/zip php_zip.c
nlopess Sun Nov 12 00:31:37 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: MFB: 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.30r2=1.31diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.30 php-src/ext/zip/php_zip.c:1.31 --- php-src/ext/zip/php_zip.c:1.30 Sat Nov 11 23:43:40 2006 +++ php-src/ext/zip/php_zip.c Sun Nov 12 00:31:37 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.30 2006/11/11 23:43:40 nlopess Exp $ */ +/* $Id: php_zip.c,v 1.31 2006/11/12 00:31:37 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -470,7 +470,9 @@ return; } if (intern-za) { - zip_close(intern-za); + if (zip_close(intern-za) != 0) { + _zip_free(intern-za); + } intern-za = NULL; } @@ -2057,7 +2059,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.30 2006/11/11 23:43:40 nlopess Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.31 2006/11/12 00:31:37 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
Re: [PHP-CVS] cvs: php-src /ext/zip php_zip.c
Hello, On 11/12/06, Nuno Lopes [EMAIL PROTECTED] wrote: nlopess Sun Nov 12 00:31:37 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: MFB: 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.30r2=1.31diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.30 php-src/ext/zip/php_zip.c:1.31 --- php-src/ext/zip/php_zip.c:1.30 Sat Nov 11 23:43:40 2006 +++ php-src/ext/zip/php_zip.c Sun Nov 12 00:31:37 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.30 2006/11/11 23:43:40 nlopess Exp $ */ +/* $Id: php_zip.c,v 1.31 2006/11/12 00:31:37 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -470,7 +470,9 @@ return; } if (intern-za) { - zip_close(intern-za); + if (zip_close(intern-za) != 0) { + _zip_free(intern-za); + } It sounds wrong. _zip_free is a private function and is used in zip_close. Can you do it there instead? itself.oo_delete.phpt works here, which error do you have? --Pierre -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/zip php_zip.c
On 11/12/06, Nuno Lopes [EMAIL PROTECTED] wrote: nlopess Sun Nov 12 00:31:37 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: MFB: 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.30r2=1.31diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.30 php-src/ext/zip/php_zip.c:1.31 --- php-src/ext/zip/php_zip.c:1.30 Sat Nov 11 23:43:40 2006 +++ php-src/ext/zip/php_zip.c Sun Nov 12 00:31:37 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.30 2006/11/11 23:43:40 nlopess Exp $ */ +/* $Id: php_zip.c,v 1.31 2006/11/12 00:31:37 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -470,7 +470,9 @@ return; } if (intern-za) { - zip_close(intern-za); + if (zip_close(intern-za) != 0) { + _zip_free(intern-za); + } It sounds wrong. _zip_free is a private function and is used in zip_close. Can you do it there instead? itself.oo_delete.phpt works here, which error do you have? --Pierre Yes, I also thought that it was a private function, but I really had to use it. The problem arises when zip_close() returns -1 (that was happending with me) and that function doesn't call _zip_free() on error (so that you can retrieve the error), thus creating a memleak. Nuno -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/zip php_zip.c
Hello, On 11/12/06, Nuno Lopes [EMAIL PROTECTED] wrote: It sounds wrong. _zip_free is a private function and is used in zip_close. Can you do it there instead? itself.oo_delete.phpt works here, which error do you have? --Pierre Yes, I also thought that it was a private function, but I really had to use it. The problem arises when zip_close() returns -1 (that was happending with me) oo_delete failed on your box? Weird, it works here on all my test systems. What do you use? and that function doesn't call _zip_free() on error (so that you can retrieve the error), thus creating a memleak. Yes I realized that now, I will add a public function to destroy a za, _zip_free must stay behind the scene :) --PIerre -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/zip php_zip.c
Hello, On 11/12/06, Nuno Lopes [EMAIL PROTECTED] wrote: It sounds wrong. _zip_free is a private function and is used in zip_close. Can you do it there instead? itself.oo_delete.phpt works here, which error do you have? --Pierre Yes, I also thought that it was a private function, but I really had to use it. The problem arises when zip_close() returns -1 (that was happending with me) oo_delete failed on your box? Weird, it works here on all my test systems. What do you use? I was testing in my gentoo box (x86). I was failing because of permission problems (AFAIR). and that function doesn't call _zip_free() on error (so that you can retrieve the error), thus creating a memleak. Yes I realized that now, I will add a public function to destroy a za, _zip_free must stay behind the scene :) OK, sure. Ah, there are a few more places where zip_free() needs to be called (basically everytime after zip_close()). Nuno -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/zip php_zip.c
pajoye Fri Nov 3 16:23:12 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - fix protos http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.27r2=1.28diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.27 php-src/ext/zip/php_zip.c:1.28 --- php-src/ext/zip/php_zip.c:1.27 Wed Nov 1 00:53:32 2006 +++ php-src/ext/zip/php_zip.c Fri Nov 3 16:23:12 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.27 2006/11/01 00:53:32 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.28 2006/11/03 16:23:12 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1877,7 +1877,7 @@ } /* }}} */ -/* {{{ proto resource getFromName(string entryname[, int len [, int flags]]) U +/* {{{ proto string getFromName(string entryname[, int len [, int flags]]) U get the contents of an entry using its name */ ZIPARCHIVE_METHOD(getFromName) { @@ -1885,7 +1885,7 @@ } /* }}} */ -/* {{{ proto resource getFromIndex(string entryname[, int len [, int flags]]) U +/* {{{ proto string getFromIndex(string entryname[, int len [, int flags]]) U get the contents of an entry using its index */ ZIPARCHIVE_METHOD(getFromIndex) { @@ -2063,7 +2063,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.27 2006/11/01 00:53:32 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.28 2006/11/03 16:23:12 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 /ext/zip php_zip.c php_zip.h /ext/zip/tests bug38943.phpt bug38944.phpt oo_extract.phpt
pajoye Tue Oct 31 14:27:09 2006 UTC Modified files: /php-src/ext/zipphp_zip.c php_zip.h /php-src/ext/zip/tests bug38943.phpt bug38944.phpt oo_extract.phpt Log: - initial unicode support . entry names will be converted to ascii. zip works with cp437 when 7zip support will be added, unicode string will be supported . path and filenames are now encoded using php_stream_path_param_encode if the filename/path is used as entry name, it is converted to ascii . the stream (getStream and zip://) needs some tweak. I'm not sure if it should return unicode or binary, neither how to change the default. For now it returns unicode (seems to be the default :) comments/suggestions welcome http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.22r2=1.23diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.22 php-src/ext/zip/php_zip.c:1.23 --- php-src/ext/zip/php_zip.c:1.22 Mon Oct 30 23:00:54 2006 +++ php-src/ext/zip/php_zip.c Tue Oct 31 14:27:09 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.22 2006/10/30 23:00:54 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.23 2006/10/31 14:27:09 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -183,13 +183,13 @@ #define RETURN_SB(sb) \ { \ array_init(return_value); \ - add_assoc_string(return_value, name, (char *)(sb)-name, 1); \ - add_assoc_long(return_value, index, (long) (sb)-index); \ - add_assoc_long(return_value, crc, (long) (sb)-crc); \ - add_assoc_long(return_value, size, (long) (sb)-size); \ - add_assoc_long(return_value, mtime, (long) (sb)-mtime); \ - add_assoc_long(return_value, comp_size, (long) (sb)-comp_size); \ - add_assoc_long(return_value, comp_method, (long) (sb)-comp_method); \ + add_ascii_assoc_string(return_value, name, (char *)(sb)-name, 1); \ + add_ascii_assoc_long(return_value, index, (long) (sb)-index); \ + add_ascii_assoc_long(return_value, crc, (long) (sb)-crc); \ + add_ascii_assoc_long(return_value, size, (long) (sb)-size); \ + add_ascii_assoc_long(return_value, mtime, (long) (sb)-mtime); \ + add_ascii_assoc_long(return_value, comp_size, (long) (sb)-comp_size); \ + add_ascii_assoc_long(return_value, comp_method, (long) (sb)-comp_method); \ } /* }}} */ @@ -238,7 +238,6 @@ return NULL; } /* }}} */ - #endif /* {{{ zend_function_entry */ @@ -851,11 +850,12 @@ /* }}} */ #ifdef ZEND_ENGINE_2_1 -/* {{{ proto mixed open(string source [, int flags]) +/* {{{ proto mixed open(string source [, int flags]) U Create new zip using source uri for output, return TRUE on success or the error code */ ZIPARCHIVE_METHOD(open) { struct zip *intern; + zval **filename_zval; char *filename; int filename_len; int err = 0; @@ -865,7 +865,7 @@ zval *this = getThis(); ze_zip_object *ze_obj = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, filename, filename_len, flags) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, Z|l, filename_zval, flags) == FAILURE) { return; } @@ -874,6 +874,10 @@ ze_obj = (ze_zip_object*) zend_object_store_get_object(this TSRMLS_CC); } + if (FAILURE == php_stream_path_param_encode(filename_zval, filename, filename_len, REPORT_ERRORS, FG(default_context))) { + RETURN_FALSE; + } + if (filename_len == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Empty string as source); RETURN_FALSE; @@ -902,7 +906,7 @@ } /* }}} */ -/* {{{ proto bool close() +/* {{{ proto bool close() U close the zip archive */ ZIPARCHIVE_METHOD(close) { @@ -931,19 +935,20 @@ } /* }}} */ -/* {{{ proto bool addFile(string filepath[, string entryname[, int start [, int length]]]) +/* {{{ proto bool addFile(string filepath[, string entryname[, int start [, int length]]]) U Add a file in a Zip archive using its path and the name to use. */ ZIPARCHIVE_METHOD(addFile) { struct zip *intern; zval *this = getThis(); + zval **filename_zval; char *filename; int filename_len; char *entry_name = NULL; int entry_name_len = 0; struct zip_source *zs; long offset_start = 0, offset_len = 0; - int cur_idx; + int cur_idx, res; char resolved_path[MAXPATHLEN + 1]; if (!this) { @@ -952,19 +957,36 @@ ZIP_FROM_OBJECT(intern, this); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|sll, - filename, filename_len, entry_name, entry_name_len, offset_start, offset_len) ==
[PHP-CVS] cvs: php-src /ext/zip php_zip.c /ext/zip/tests oo_stream.phpt
pajoye Tue Oct 31 19:03:57 2006 UTC Modified files: /php-src/ext/zipphp_zip.c /php-src/ext/zip/tests oo_stream.phpt Log: - fix possible leak in addFile when an unicode filename is given - Mark getStream as Unicode ready, the tests was wrong $unistring .= fread($fpbinary); $unistring remains as unicode. http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.23r2=1.24diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.23 php-src/ext/zip/php_zip.c:1.24 --- php-src/ext/zip/php_zip.c:1.23 Tue Oct 31 14:27:09 2006 +++ php-src/ext/zip/php_zip.c Tue Oct 31 19:03:57 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.23 2006/10/31 14:27:09 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.24 2006/10/31 19:03:57 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -990,11 +990,18 @@ } if(!expand_filepath(filename, resolved_path TSRMLS_CC)) { + if (Z_TYPE_PP(filename_zval) == IS_UNICODE) { + efree(entry_name); + } + RETURN_FALSE; } zs = zip_source_file(intern, resolved_path, 0, 0); if (!zs) { + if (Z_TYPE_PP(filename_zval) == IS_UNICODE) { + efree(entry_name); + } RETURN_FALSE; } @@ -1817,7 +1824,7 @@ } /* }}} */ -/* {{{ proto resource getStream(string entryname) +/* {{{ proto resource getStream(string entryname) U get a stream for an entry using its name */ ZIPARCHIVE_METHOD(getStream) { @@ -1986,7 +1993,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.23 2006/10/31 14:27:09 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.24 2006/10/31 19:03: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/oo_stream.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/zip/tests/oo_stream.phpt diff -u php-src/ext/zip/tests/oo_stream.phpt:1.1 php-src/ext/zip/tests/oo_stream.phpt:1.2 --- php-src/ext/zip/tests/oo_stream.phpt:1.1Mon Oct 30 17:43:21 2006 +++ php-src/ext/zip/tests/oo_stream.phptTue Oct 31 19:03:57 2006 @@ -2,7 +2,7 @@ getStream --SKIPIF-- ?php -/* $Id: oo_stream.phpt,v 1.1 2006/10/30 17:43:21 pajoye Exp $ */ +/* $Id: oo_stream.phpt,v 1.2 2006/10/31 19:03:57 pajoye Exp $ */ if(!extension_loaded('zip')) die('skip'); ? --FILE-- @@ -18,7 +18,7 @@ var_dump($fp); if(!$fp) exit(\n); -$contents = ''; +$contents = b''; while (!feof($fp)) { $contents .= fread($fp, 255); } @@ -32,7 +32,7 @@ if (!$fp) { exit(cannot open\n); } -$contents = ''; +$contents = b''; while (!feof($fp)) { $contents .= fread($fp, 2); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/zip php_zip.c
pajoye Tue Oct 31 19:34:41 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - mark extractTo as U-ready, path and filenames are now encoded correctly http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.24r2=1.25diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.24 php-src/ext/zip/php_zip.c:1.25 --- php-src/ext/zip/php_zip.c:1.24 Tue Oct 31 19:03:57 2006 +++ php-src/ext/zip/php_zip.c Tue Oct 31 19:34:41 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.24 2006/10/31 19:03:57 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.25 2006/10/31 19:34:41 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1658,6 +1658,7 @@ zval **pathto_zval; char *pathto; char *file; + int file_len; int pathto_len; int ret, i; @@ -1691,9 +1692,22 @@ if (zval_files) { switch (Z_TYPE_P(zval_files)) { case IS_UNICODE: + if (FAILURE == php_stream_path_param_encode(zval_files, file, file_len, REPORT_ERRORS, FG(default_context))) { + RETURN_FALSE; + } case IS_STRING: - file = Z_STRVAL_P(zval_files); + if (Z_TYPE_P(zval_files) != IS_UNICODE) { + file_len = Z_STRLEN_P(zval_files); + file = Z_STRVAL_P(zval_files); + } + if (file_len 1) { + efree(file); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, Empty string as filename); + RETURN_FALSE; + } + if (!php_zip_extract_file(intern, pathto, file TSRMLS_CC)) { + efree(file); RETURN_FALSE; } break; @@ -1707,9 +1721,23 @@ switch (Z_TYPE_PP(zval_file)) { case IS_LONG: break; + case IS_UNICODE: + if (FAILURE == php_stream_path_param_encode(zval_file, file, file_len, REPORT_ERRORS, FG(default_context))) { + RETURN_FALSE; + } case IS_STRING: - file = Z_STRVAL_PP(zval_file); + if (Z_TYPE_P(zval_files) != IS_UNICODE) { + file_len = Z_STRLEN_PP(zval_file); + file = Z_STRVAL_PP(zval_file); + } + if (file_len 1) { + efree(file); + php_error_docref(NULL TSRMLS_CC, E_NOTICE, Empty string as filename); + RETURN_FALSE; + } + if (!php_zip_extract_file(intern, pathto, file TSRMLS_CC)) { + efree(file); RETURN_FALSE; } break; @@ -1993,7 +2021,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.24 2006/10/31 19:03:57 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.25 2006/10/31 19:34:41 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 /ext/zip php_zip.c
pajoye Tue Oct 31 23:25:41 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - use zip_name_locate in getCommentName http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.25r2=1.26diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.25 php-src/ext/zip/php_zip.c:1.26 --- php-src/ext/zip/php_zip.c:1.25 Tue Oct 31 19:34:41 2006 +++ php-src/ext/zip/php_zip.c Tue Oct 31 23:25:41 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.25 2006/10/31 19:34:41 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.26 2006/10/31 23:25:41 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1306,6 +1306,10 @@ return; } + if (name_len 1) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, Empty string as entry name); + } + idx = zip_name_locate(intern, name, 0); if (idx 0) { RETURN_FALSE; @@ -1347,12 +1351,11 @@ { struct zip *intern; zval *this = getThis(); - int name_len; + int name_len, idx; long flags = 0; int comment_len = 0; const char * comment; char *name; - struct zip_stat sb; if (!this) { RETURN_FALSE; @@ -1365,8 +1368,17 @@ return; } - PHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb); - comment = zip_get_file_comment(intern, sb.index, comment_len, (int)flags); + if (name_len 1) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, Empty string as entry name); + RETURN_FALSE; + } + + idx = zip_name_locate(intern, name, 0); + if (idx 0) { + RETURN_FALSE; + } + + comment = zip_get_file_comment(intern, idx, comment_len, (int)flags); RETURN_STRINGL((char *)comment, (long)comment_len, 1); } /* }}} */ @@ -2021,7 +2033,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.25 2006/10/31 19:34:41 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.26 2006/10/31 23:25:41 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 /ext/zip php_zip.c
pajoye Mon Oct 30 17:28:29 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - fix leak in statName and statIndex - use zip_locate_name instead of zip_stat in setCommentName (faster and work around for a possible bug) http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.20r2=1.21diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.20 php-src/ext/zip/php_zip.c:1.21 --- php-src/ext/zip/php_zip.c:1.20 Wed Oct 25 12:32:10 2006 +++ php-src/ext/zip/php_zip.c Mon Oct 30 17:28:29 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.20 2006/10/25 12:32:10 bjori Exp $ */ +/* $Id: php_zip.c,v 1.21 2006/10/30 17:28:29 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -183,7 +183,7 @@ #define RETURN_SB(sb) \ { \ array_init(return_value); \ - add_assoc_string(return_value, name, estrdup((sb)-name), 0); \ + add_assoc_string(return_value, name, (char *)(sb)-name, 1); \ add_assoc_long(return_value, index, (long) (sb)-index); \ add_assoc_long(return_value, crc, (long) (sb)-crc); \ add_assoc_long(return_value, size, (long) (sb)-size); \ @@ -1250,7 +1250,7 @@ zval *this = getThis(); int comment_len, name_len; char * comment, *name; - struct zip_stat sb; + int idx; if (!this) { RETURN_FALSE; @@ -1263,9 +1263,11 @@ return; } - - PHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb); - PHP_ZIP_SET_FILE_COMMENT(intern, sb.index, comment, comment_len); + idx = zip_name_locate(intern, name, 0); + if (idx 0) { + RETURN_FALSE; + } + PHP_ZIP_SET_FILE_COMMENT(intern, idx, comment, comment_len); } /* }}} */ @@ -1937,7 +1939,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.20 2006/10/25 12:32:10 bjori Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.21 2006/10/30 17:28:29 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 /ext/zip php_zip.c
pajoye Mon Oct 30 23:00:54 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - nuke flags local variable, it is constant http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.21r2=1.22diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.21 php-src/ext/zip/php_zip.c:1.22 --- php-src/ext/zip/php_zip.c:1.21 Mon Oct 30 17:28:29 2006 +++ php-src/ext/zip/php_zip.c Mon Oct 30 23:00:54 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.21 2006/10/30 17:28:29 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.22 2006/10/30 23:00:54 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -639,7 +639,6 @@ 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, zip_dp) == FAILURE) { @@ -654,7 +653,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); @@ -1939,7 +1938,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.21 2006/10/30 17:28:29 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.22 2006/10/30 23:00:54 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 /ext/zip php_zip.c
bjori Wed Oct 25 12:31:12 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: Fix protos http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.18r2=1.19diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.18 php-src/ext/zip/php_zip.c:1.19 --- php-src/ext/zip/php_zip.c:1.18 Sun Oct 22 00:43:23 2006 +++ php-src/ext/zip/php_zip.c Wed Oct 25 12:31:12 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.18 2006/10/22 00:43:23 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.19 2006/10/25 12:31:12 bjori Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -902,7 +902,7 @@ } /* }}} */ -/* {{{ proto resource close() +/* {{{ proto bool close() close the zip archive */ ZIPARCHIVE_METHOD(close) { @@ -999,7 +999,7 @@ } /* }}} */ -/* {{{ proto resource addFromString(string name, string content) +/* {{{ proto bool addFromString(string name, string content) Add a file using content and the entry name */ ZIPARCHIVE_METHOD(addFromString) { @@ -1064,7 +1064,7 @@ } /* }}} */ -/* {{{ proto resource statName(string filename[, int flags]) +/* {{{ proto array statName(string filename[, int flags]) Returns the information about a the zip entry filename */ ZIPARCHIVE_METHOD(statName) { @@ -1120,7 +1120,7 @@ } /* }}} */ -/* {{{ proto resource locateName(string filename[, int flags]) +/* {{{ proto int locateName(string filename[, int flags]) Returns the index of the entry named filename in the archive */ ZIPARCHIVE_METHOD(locateName) { @@ -1160,7 +1160,7 @@ } /* }}} */ -/* {{{ proto resource getNameIndex(int index [, int flags]) +/* {{{ proto string getNameIndex(int index [, int flags]) Returns the name of the file at position index */ ZIPARCHIVE_METHOD(getNameIndex) { @@ -1190,7 +1190,7 @@ } /* }}} */ -/* {{{ proto resource setArchiveComment(string name, string comment) +/* {{{ proto bool setArchiveComment(string name, string comment) Set or remove (NULL/'') the comment of the archive */ ZIPARCHIVE_METHOD(setArchiveComment) { @@ -1216,7 +1216,7 @@ } /* }}} */ -/* {{{ proto resource getArchiveComment() +/* {{{ proto string getArchiveComment() Returns the comment of an entry using its index */ ZIPARCHIVE_METHOD(getArchiveComment) { @@ -1241,7 +1241,7 @@ } /* }}} */ -/* {{{ proto resource setCommentName(string name, string comment) +/* {{{ proto bool setCommentName(string name, string comment) Set or remove (NULL/'') the comment of an entry using its Name */ ZIPARCHIVE_METHOD(setCommentName) { @@ -1268,7 +1268,7 @@ } /* }}} */ -/* {{{ proto resource setCommentIndex(int index, string comment) +/* {{{ proto bool setCommentIndex(int index, string comment) Set or remove (NULL/'') the comment of an entry using its index */ ZIPARCHIVE_METHOD(setCommentIndex) { @@ -1295,7 +1295,7 @@ } /* }}} */ -/* {{{ proto resource getCommentName(string name) +/* {{{ proto string getCommentName(string name) Returns the comment of an entry using its name */ ZIPARCHIVE_METHOD(getCommentName) { @@ -1325,7 +1325,7 @@ } /* }}} */ -/* {{{ proto resource getCommentIndex(int index) +/* {{{ proto string getCommentIndex(int index) Returns the comment of an entry using its index */ ZIPARCHIVE_METHOD(getCommentIndex) { @@ -1353,7 +1353,7 @@ } /* }}} */ -/* {{{ proto resource deleteIndex(int index) +/* {{{ proto bool deleteIndex(int index) Delete a file using its index */ ZIPARCHIVE_METHOD(deleteIndex) { @@ -1383,7 +1383,7 @@ } /* }}} */ -/* {{{ proto resource deleteName(string name) +/* {{{ proto bool deleteName(string name) Delete a file using its index */ ZIPARCHIVE_METHOD(deleteName) { @@ -1414,7 +1414,7 @@ } /* }}} */ -/* {{{ proto resource renameIndex(int index, string new_name) +/* {{{ proto bool renameIndex(int index, string new_name) Rename an entry selected by its index to new_name */ ZIPARCHIVE_METHOD(renameIndex) { @@ -1450,7 +1450,7 @@ } /* }}} */ -/* {{{ proto resource renameName(string name, string new_name) +/* {{{ proto bool renameName(string name, string new_name) Rename an entry selected by its name to new_name */ ZIPARCHIVE_METHOD(renameName) { @@ -1484,7 +1484,7 @@ } /* }}} */ -/* {{{ proto resource unchangeIndex(int index) +/* {{{ proto bool unchangeIndex(int index) Changes to the file at position index are reverted */ ZIPARCHIVE_METHOD(unchangeIndex) { @@ -1514,7 +1514,7 @@ } /* }}} */ -/* {{{ proto resource unchangeName(string name) +/* {{{ proto bool unchangeName(string name) Changes to the file named 'name' are reverted */ ZIPARCHIVE_METHOD(unchangeName) { @@ -1548,7 +1548,7 @@ } /* }}} */ -/* {{{ proto resource unchangeAll() +/* {{{ proto bool unchangeAll() All changes to files and global information in archive are reverted */ ZIPARCHIVE_METHOD(unchangeAll) { @@ -1569,7 +1569,7 @@ } /* }}} */ -/* {{{ proto resource unchangeAll() +/* {{{ proto bool
[PHP-CVS] cvs: php-src /ext/zip php_zip.c
bjori Wed Oct 25 12:32:11 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: Missing RETURN_TRUE inside the PHP_ZIP_SET_FILE_COMMENT macro http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.19r2=1.20diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.19 php-src/ext/zip/php_zip.c:1.20 --- php-src/ext/zip/php_zip.c:1.19 Wed Oct 25 12:31:12 2006 +++ php-src/ext/zip/php_zip.c Wed Oct 25 12:32:10 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.19 2006/10/25 12:31:12 bjori Exp $ */ +/* $Id: php_zip.c,v 1.20 2006/10/25 12:32:10 bjori Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -65,7 +65,8 @@ } \ } else if (zip_set_file_comment(intern, index, comment, comment_len) 0) { \ RETURN_FALSE; \ - } + } \ + RETURN_TRUE; /* }}} */ @@ -1936,7 +1937,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.19 2006/10/25 12:31:12 bjori Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.20 2006/10/25 12:32:10 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 /ext/zip php_zip.c
pajoye Sun Oct 22 00:43:23 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - remove remaining mode arguments in the old api http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.17r2=1.18diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.17 php-src/ext/zip/php_zip.c:1.18 --- php-src/ext/zip/php_zip.c:1.17 Sat Oct 7 22:55:18 2006 +++ php-src/ext/zip/php_zip.c Sun Oct 22 00:43:23 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.17 2006/10/07 22:55:18 bjori Exp $ */ +/* $Id: php_zip.c,v 1.18 2006/10/22 00:43:23 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -631,7 +631,7 @@ } /* }}} */ -/* {{{ 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) { @@ -641,7 +641,7 @@ 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); @@ -719,7 +719,7 @@ } /* }}} */ -/* {{{ 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) { @@ -1936,7 +1936,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.17 2006/10/07 22:55:18 bjori Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.18 2006/10/22 00:43:23 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 /ext/zip php_zip.c /ext/zip/tests 38943.phpt
pajoye Sun Sep 24 22:27:20 2006 UTC Added files: /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.15r2=1.16diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.15 php-src/ext/zip/php_zip.c:1.16 --- php-src/ext/zip/php_zip.c:1.15 Fri Sep 15 12:10:50 2006 +++ php-src/ext/zip/php_zip.c Sun Sep 24 22:27:19 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.15 2006/09/15 12:10:50 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.16 2006/09/24 22:27:19 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -506,7 +506,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; @@ -514,8 +513,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 *)); @@ -1870,7 +1868,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; @@ -1962,7 +1959,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.15 2006/09/15 12:10:50 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.16 2006/09/24 22:27:19 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 /ext/zip php_zip.c /ext/zip/tests bug8700.phpt
pajoye Fri Sep 15 12:10:50 2006 UTC Added files: /php-src/ext/zip/tests bug8700.phpt Modified files: /php-src/ext/zipphp_zip.c Log: - PECL Bug #8700, zipArchive::getFromIndex() fails http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.14r2=1.15diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.14 php-src/ext/zip/php_zip.c:1.15 --- php-src/ext/zip/php_zip.c:1.14 Tue Sep 12 12:04:03 2006 +++ php-src/ext/zip/php_zip.c Fri Sep 15 12:10:50 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.14 2006/09/12 12:04:03 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.15 2006/09/15 12:10:50 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1719,7 +1719,7 @@ char *filename; int filename_len; - long index; + long index = -1; long flags = 0; long len = 0; @@ -1753,8 +1753,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; } @@ -1958,7 +1962,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.14 2006/09/12 12:04:03 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.15 2006/09/15 12:10:50 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 /ext/zip php_zip.c
pajoye Tue Sep 12 12:04:03 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - MFB: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.13r2=1.14diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.13 php-src/ext/zip/php_zip.c:1.14 --- php-src/ext/zip/php_zip.c:1.13 Wed Sep 6 19:50:22 2006 +++ php-src/ext/zip/php_zip.c Tue Sep 12 12:04:03 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.13 2006/09/06 19:50:22 bjori Exp $ */ +/* $Id: php_zip.c,v 1.14 2006/09/12 12:04:03 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -971,10 +971,10 @@ entry_name_len = filename_len; } - if (!VCWD_REALPATH(filename, resolved_path)) { + if(!expand_filepath(filename, resolved_path TSRMLS_CC)) { RETURN_FALSE; } - + zs = zip_source_file(intern, resolved_path, 0, 0); if (!zs) { RETURN_FALSE; @@ -1958,7 +1958,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.13 2006/09/06 19:50:22 bjori Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.14 2006/09/12 12:04:03 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 /ext/zip php_zip.c
nlopess Wed Sep 6 15:13:16 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: fix a few more zend_parse_parameters() issues http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.10r2=1.11diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.10 php-src/ext/zip/php_zip.c:1.11 --- php-src/ext/zip/php_zip.c:1.10 Sat Aug 26 12:29:59 2006 +++ php-src/ext/zip/php_zip.c Wed Sep 6 15:13:16 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.10 2006/08/26 12:29:59 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.11 2006/09/06 15:13:16 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -597,7 +597,7 @@ zip_rsrc *rsrc_int; int err = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, filename, filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, filename, filename_len) == FAILURE) { return; } @@ -643,7 +643,7 @@ 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|l, zip_dp, flags) == FAILURE) { return; } ZEND_FETCH_RESOURCE(rsrc_int, zip_rsrc *, zip_dp, -1, le_zip_dir_name, le_zip_dir); @@ -1205,7 +1205,7 @@ { struct zip *intern; zval *this = getThis(); - long comment_len = 0; + int comment_len; char * comment; if (!this) { @@ -1258,7 +1258,7 @@ { struct zip *intern; zval *this = getThis(); - long comment_len = 0, name_len = 0; + int comment_len, name_len; char * comment, *name; struct zip_stat sb; @@ -1286,7 +1286,8 @@ { struct zip *intern; zval *this = getThis(); - long index, comment_len = 0; + long index + int comment_len; char * comment; struct zip_stat sb; @@ -1313,7 +1314,8 @@ { struct zip *intern; zval *this = getThis(); - long name_len = 0, flags = 0; + int name_len; + long flags = 0; int comment_len = 0; const char * comment; char *name; @@ -1403,8 +1405,8 @@ { struct zip *intern; zval *this = getThis(); - long name_len = 0; - char *name; + int name_len; + char *name; struct zip_stat sb; if (!this) { @@ -1956,7 +1958,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.10 2006/08/26 12:29:59 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.11 2006/09/06 15:13:16 nlopess 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 /ext/zip php_zip.c
bjori Wed Sep 6 19:50:22 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: fix build http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.12r2=1.13diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.12 php-src/ext/zip/php_zip.c:1.13 --- php-src/ext/zip/php_zip.c:1.12 Wed Sep 6 17:39:33 2006 +++ php-src/ext/zip/php_zip.c Wed Sep 6 19:50:22 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.12 2006/09/06 17:39:33 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.13 2006/09/06 19:50:22 bjori Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1286,7 +1286,7 @@ { struct zip *intern; zval *this = getThis(); - long index + long index; int comment_len; char * comment; struct zip_stat sb; @@ -1958,7 +1958,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.12 2006/09/06 17:39:33 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.13 2006/09/06 19:50:22 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 /ext/zip php_zip.c
pajoye Sat Aug 26 12:29:59 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - MFB: 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.9r2=1.10diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.9 php-src/ext/zip/php_zip.c:1.10 --- php-src/ext/zip/php_zip.c:1.9 Fri Aug 25 16:03:50 2006 +++ php-src/ext/zip/php_zip.c Sat Aug 26 12:29:59 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.9 2006/08/25 16:03:50 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.10 2006/08/26 12:29:59 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -882,7 +882,7 @@ RETURN_FALSE; } - if (!VCWD_REALPATH(filename, resolved_path)) { + if(!expand_filepath(filename, resolved_path TSRMLS_CC)) { RETURN_FALSE; } @@ -1956,7 +1956,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.9 2006/08/25 16:03:50 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.10 2006/08/26 12:29:59 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 /ext/zip php_zip.c
pajoye Fri Aug 25 16:03:50 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - MFB: bundled version matches pecl release 1.7.1 http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.8r2=1.9diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.8 php-src/ext/zip/php_zip.c:1.9 --- php-src/ext/zip/php_zip.c:1.8 Thu Aug 24 17:54:36 2006 +++ php-src/ext/zip/php_zip.c Fri Aug 25 16:03:50 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.8 2006/08/24 17:54:36 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.9 2006/08/25 16:03:50 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1956,8 +1956,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.8 2006/08/24 17:54:36 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.9 2006/08/25 16:03:50 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 /ext/zip php_zip.c
pajoye Thu Aug 24 17:31:21 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - MFB: solve the relative path issues in TS environment http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.6r2=1.7diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.6 php-src/ext/zip/php_zip.c:1.7 --- php-src/ext/zip/php_zip.c:1.6 Mon Aug 14 15:39:28 2006 +++ php-src/ext/zip/php_zip.c Thu Aug 24 17:31:20 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.6 2006/08/14 15:39:28 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.7 2006/08/24 17:31:20 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -862,6 +862,7 @@ int filename_len; int err = 0; long flags = 0; + char resolved_path[MAXPATHLEN + 1]; zval *this = getThis(); ze_zip_object *ze_obj = NULL; @@ -880,6 +881,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); @@ -888,7 +894,7 @@ efree(ze_obj-filename); } - intern = zip_open(filename, flags, err); + intern = zip_open(resolved_path, flags, err); if (!intern || err) { RETURN_LONG((long)err); } @@ -941,6 +947,7 @@ struct zip_source *zs; long offset_start = 0, offset_len = 0; int cur_idx; + char resolved_path[MAXPATHLEN + 1]; if (!this) { RETURN_FALSE; @@ -964,7 +971,11 @@ entry_name_len = filename_len; } - 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; } @@ -1945,7 +1956,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.6 2006/08/14 15:39:28 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.7 2006/08/24 17:31:20 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 /ext/zip php_zip.c
pajoye Thu Aug 24 17:54:36 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - store the resolved path http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.7r2=1.8diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.7 php-src/ext/zip/php_zip.c:1.8 --- php-src/ext/zip/php_zip.c:1.7 Thu Aug 24 17:31:20 2006 +++ php-src/ext/zip/php_zip.c Thu Aug 24 17:54:36 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.7 2006/08/24 17:31:20 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.8 2006/08/24 17:54:36 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -898,7 +898,7 @@ 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; @@ -1956,7 +1956,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.7 2006/08/24 17:31:20 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.8 2006/08/24 17:54:36 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 /ext/zip php_zip.c
pajoye Mon Aug 14 15:39:29 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - MFB: nuke unused parameter (not present in old versions) http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.5r2=1.6diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.5 php-src/ext/zip/php_zip.c:1.6 --- php-src/ext/zip/php_zip.c:1.5 Sun Aug 13 23:39:57 2006 +++ php-src/ext/zip/php_zip.c Mon Aug 14 15:39:28 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.5 2006/08/13 23:39:57 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.6 2006/08/14 15:39:28 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -588,23 +588,22 @@ 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|l, filename, filename_len) == FAILURE) { return; } 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); @@ -727,12 +726,12 @@ 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; } @@ -1946,7 +1945,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.5 2006/08/13 23:39:57 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.6 2006/08/14 15:39:28 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 /ext/zip php_zip.c
pajoye Sun Aug 13 20:54:27 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: - remove all safe mode checks instead of borking the sources...Y http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.3r2=1.4diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.3 php-src/ext/zip/php_zip.c:1.4 --- php-src/ext/zip/php_zip.c:1.3 Sun Aug 13 20:16:48 2006 +++ php-src/ext/zip/php_zip.c Sun Aug 13 20:54:27 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.3 2006/08/13 20:16:48 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.4 2006/08/13 20:54:27 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -38,17 +38,6 @@ #define le_zip_entry_name Zip Entry /* }}} */ -/* {{{ SAFEMODE_CHECKFILE(filename) */ -#if (PHP_MAJOR_VERSION 6) -#define SAFEMODE_CHECKFILE(filename) \ - if (PG(safe_mode) (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC) { \ - RETURN_FALSE; \ - } -#else -#define SAFEMODE_CHECKFILE(filename); -#endif -/* }}} */ - /* {{{ PHP_ZIP_STAT_INDEX(za, index, flags, sb) */ #define PHP_ZIP_STAT_INDEX(za, index, flags, sb) \ if (zip_stat_index(za, index, flags, sb) != 0) { \ @@ -119,8 +108,6 @@ php_basename(file, file_len, NULL, 0, file_basename, (int *)file_basename_len TSRMLS_CC); - SAFEMODE_CHECKFILE(file_dirname_fullpath); - /* let see if the path already exists */ if (php_stream_stat_path(file_dirname_fullpath, ssb) 0) { ret = php_stream_mkdir(file_dirname_fullpath, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL); @@ -145,12 +132,6 @@ return 0; } - /* check again the full path, not sure if it -* is required, does a file can have a different -* safemode status as its parent folder? -*/ - SAFEMODE_CHECKFILE(fullpath); - zf = zip_fopen(za, file, 0); if (zf == NULL) { efree(fullpath); @@ -158,11 +139,9 @@ efree(file_basename); return 0; } -#if (PHP_MAJOR_VERSION 6) - stream = php_stream_open_wrapper(fullpath, w+b, REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); -#else + stream = php_stream_open_wrapper(fullpath, w+b, REPORT_ERRORS, NULL); -#endif + n = 0; if (stream) { while ((n=zip_fread(zf, b, sizeof(b))) 0) php_stream_write(stream, b, n); @@ -623,8 +602,6 @@ return; } - SAFEMODE_CHECKFILE(filename); - rsrc_int = (zip_rsrc *)emalloc(sizeof(zip_rsrc)); rsrc_int-za = zip_open(filename, mode, err); @@ -988,8 +965,6 @@ entry_name_len = filename_len; } - SAFEMODE_CHECKFILE(filename); - zs = zip_source_file(intern, filename, 0, 0); if (!zs) { RETURN_FALSE; @@ -1959,7 +1934,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.3 2006/08/13 20:16:48 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.4 2006/08/13 20:54:27 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 /ext/zip php_zip.c /ext/zip/tests oo_namelocate.phpt
pajoye Sun Aug 13 23:39:57 2006 UTC Modified files: /php-src/ext/zipphp_zip.c /php-src/ext/zip/tests oo_namelocate.phpt Log: - 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.4r2=1.5diff_format=u Index: php-src/ext/zip/php_zip.c diff -u php-src/ext/zip/php_zip.c:1.4 php-src/ext/zip/php_zip.c:1.5 --- php-src/ext/zip/php_zip.c:1.4 Sun Aug 13 20:54:27 2006 +++ php-src/ext/zip/php_zip.c Sun Aug 13 23:39:57 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_zip.c,v 1.4 2006/08/13 20:54:27 pajoye Exp $ */ +/* $Id: php_zip.c,v 1.5 2006/08/13 23:39:57 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1126,6 +1126,7 @@ char *name; int name_len; long flags = 0; + long idx = -1; if (!this) { RETURN_FALSE; @@ -1142,7 +1143,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); + } } /* }}} */ @@ -1934,7 +1946,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.4 2006/08/13 20:54:27 pajoye Exp $); + php_info_print_table_row(2, Extension Version,$Id: php_zip.c,v 1.5 2006/08/13 23:39:57 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.2diff_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.2 --- 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:39:57 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.2 2006/08/13 23:39:57 pajoye Exp $ */ if(!extension_loaded('zip')) die('skip'); ? --FILE-- @@ -31,15 +31,15 @@ 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 /ext/zip php_zip.c
iliaa Fri Jul 28 14:00:07 2006 UTC Modified files: /php-src/ext/zipphp_zip.c Log: MFB: Cleanup phpinfo() output http://cvs.php.net/viewvc.cgi/php-src/ext/zip/php_zip.c?r1=1.1r2=1.2diff_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.2 --- 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 14:00:07 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.2 2006/07/28 14:00:07 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.2 2006/07/28 14:00:07 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