sfox Sat Jun 21 18:57:53 2008 UTC Modified files: (Branch: PHP_5_3) /php-src/ext/phar Makefile.frag phar.c phar_object.c util.c Log: - ws
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/Makefile.frag?r1=1.14.2.5&r2=1.14.2.6&diff_format=u Index: php-src/ext/phar/Makefile.frag diff -u php-src/ext/phar/Makefile.frag:1.14.2.5 php-src/ext/phar/Makefile.frag:1.14.2.6 --- php-src/ext/phar/Makefile.frag:1.14.2.5 Wed Jun 4 16:38:13 2008 +++ php-src/ext/phar/Makefile.frag Sat Jun 21 18:57:53 2008 @@ -43,4 +43,3 @@ install-pharcmd: pharcmd [EMAIL PROTECTED](mkinstalldirs) $(INSTALL_ROOT)$(bindir) $(INSTALL) $(builddir)/phar.phar $(INSTALL_ROOT)$(bindir) - http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.c?r1=1.370.2.26&r2=1.370.2.27&diff_format=u Index: php-src/ext/phar/phar.c diff -u php-src/ext/phar/phar.c:1.370.2.26 php-src/ext/phar/phar.c:1.370.2.27 --- php-src/ext/phar/phar.c:1.370.2.26 Sat Jun 21 17:05:18 2008 +++ php-src/ext/phar/phar.c Sat Jun 21 18:57:53 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: phar.c,v 1.370.2.26 2008/06/21 17:05:18 cellog Exp $ */ +/* $Id: phar.c,v 1.370.2.27 2008/06/21 18:57:53 sfox Exp $ */ #define PHAR_MAIN 1 #include "phar_internal.h" @@ -1818,9 +1818,9 @@ if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&cached_phars, &key, &keylen, &unused, 0, NULL)) { break; } - + PHAR_STR(key, str_key); - + if (keylen > (uint) filename_len) { zend_hash_move_forward(&cached_phars); continue; @@ -2143,39 +2143,38 @@ } halt_offset = Z_LVAL(*halt_constant); FREE_ZVAL(halt_constant); - #if PHP_MAJOR_VERSION < 6 if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) { - return FAILURE; - } + return FAILURE; + } #endif if (php_check_open_basedir(fname TSRMLS_CC)) { return FAILURE; - } + } fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, &actual); if (!fp) { - if (error) { + if (error) { spprintf(error, 0, "unable to open phar for reading \"%s\"", fname); - } + } if (actual) { - efree(actual); - } + efree(actual); + } return FAILURE; - } + } if (actual) { - fname = actual; + fname = actual; fname_len = strlen(actual); - } + } ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, REPORT_ERRORS, NULL, error TSRMLS_CC); - if (actual) { + if (actual) { efree(actual); - } - return ret; + } + return ret; } /* }}} */ @@ -2448,6 +2447,7 @@ } return EOF; } + if (error) { *error = NULL; } @@ -2459,6 +2459,7 @@ if (phar->is_zip) { return phar_zip_flush(phar, user_stub, len, convert, error TSRMLS_CC); } + if (phar->is_tar) { return phar_tar_flush(phar, user_stub, len, convert, error TSRMLS_CC); } @@ -2966,11 +2967,12 @@ char sig_buf[4]; php_stream_rewind(newfile); + if (phar->signature) { efree(phar->signature); phar->signature = NULL; } - + switch(phar->sig_flags) { #if !HAVE_HASH_EXT case PHAR_SIG_SHA512: @@ -3348,7 +3350,7 @@ } PHAR_GLOBALS->cached_fp = stuff; } - zend_hash_init(&(PHAR_GLOBALS->phar_SERVER_mung_list), 5, zend_get_hash_value, NULL, 0); + zend_hash_init(&(PHAR_GLOBALS->phar_SERVER_mung_list), 5, zend_get_hash_value, NULL, 0); PHAR_G(cwd) = NULL; PHAR_G(cwd_len) = 0; PHAR_G(cwd_init) = 0; @@ -3406,7 +3408,7 @@ php_info_print_table_header(2, "Phar: PHP Archive support", "enabled"); php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION); php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION); - php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.26 $"); + php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.27 $"); php_info_print_table_row(2, "Phar-based phar archives", "enabled"); php_info_print_table_row(2, "Tar-based phar archives", "enabled"); php_info_print_table_row(2, "ZIP-based phar archives", "enabled"); @@ -3438,9 +3440,9 @@ */ static zend_module_dep phar_deps[] = { ZEND_MOD_OPTIONAL("apc") + ZEND_MOD_OPTIONAL("bz2") ZEND_MOD_OPTIONAL("openssl") ZEND_MOD_OPTIONAL("zlib") - ZEND_MOD_OPTIONAL("bz2") #if HAVE_SPL ZEND_MOD_REQUIRED("spl") #endif http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar_object.c?r1=1.266.2.27&r2=1.266.2.28&diff_format=u Index: php-src/ext/phar/phar_object.c diff -u php-src/ext/phar/phar_object.c:1.266.2.27 php-src/ext/phar/phar_object.c:1.266.2.28 --- php-src/ext/phar/phar_object.c:1.266.2.27 Sat Jun 21 06:55:56 2008 +++ php-src/ext/phar/phar_object.c Sat Jun 21 18:57:53 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: phar_object.c,v 1.266.2.27 2008/06/21 06:55:56 cellog Exp $ */ +/* $Id: phar_object.c,v 1.266.2.28 2008/06/21 18:57:53 sfox Exp $ */ #include "phar_internal.h" #include "func_interceptors.h" @@ -1178,13 +1178,16 @@ } if (phar_open_or_create_filename(fname, fname_len, alias, alias_len, is_data, REPORT_ERRORS, &phar_data, &error TSRMLS_CC) == FAILURE) { + if (fname == arch) { efree(arch); fname = save_fname; } + if (entry) { efree(entry); } + if (error) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "%s", error); @@ -1193,6 +1196,7 @@ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Phar creation or opening failed"); } + return; } @@ -1262,10 +1266,12 @@ add_next_index_stringl(return_value, "MD5", 3, 1); add_next_index_stringl(return_value, "SHA-1", 5, 1); + #if HAVE_HASH_EXT add_next_index_stringl(return_value, "SHA-256", 7, 1); add_next_index_stringl(return_value, "SHA-512", 7, 1); #endif + #if PHAR_HAVE_OPENSSL add_next_index_stringl(return_value, "OpenSSL", 7, 1); #else @@ -1958,6 +1964,7 @@ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Unable to add newly converted phar \"%s\" to the list of phars, new phar name is in phar.cache_list", phar->fname); return NULL; } + if (SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), newpath, phar->fname_len, (void **) &pphar)) { if ((*pphar)->fname_len == phar->fname_len && !memcmp((*pphar)->fname, phar->fname, phar->fname_len)) { if (!zend_hash_num_elements(&phar->manifest)) { @@ -2135,7 +2142,7 @@ } newentry.is_modified = 1; newentry.phar = phar; - newentry.old_flags = newentry.flags & ~PHAR_ENT_COMPRESSION_MASK; /* remove compression from old_flags */ + newentry.old_flags = newentry.flags & ~PHAR_ENT_COMPRESSION_MASK; /* remove compression from old_flags */ phar_set_inode(&newentry TSRMLS_CC); zend_hash_add(&(phar->manifest), newentry.filename, newentry.filename_len, (void*)&newentry, sizeof(phar_entry_info), NULL); phar_add_virtual_dirs(phar, newentry.filename, newentry.filename_len TSRMLS_CC); @@ -2479,6 +2486,7 @@ "Cannot write out phar archive, phar is read-only"); RETURN_FALSE; } + /* invalidate phar cache */ PHAR_G(last_phar) = NULL; PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL; @@ -2735,7 +2743,7 @@ /* {{{ proto array Phar::setSignatureAlgorithm(int sigtype[, string privatekey]) * Sets the signature algorithm for a phar and applies it. The signature * algorithm must be one of Phar::MD5, Phar::SHA1, Phar::SHA256, - * Phar::SHA512, or Phar::OPENSSL. Note that zip- and tar- based phar archives + * Phar::SHA512, or Phar::OPENSSL. Note that zip- based phar archives * cannot support signatures. */ PHP_METHOD(Phar, setSignatureAlgorithm) @@ -2744,12 +2752,13 @@ char *error, *key = NULL; int key_len = 0; PHAR_ARCHIVE_OBJECT(); - + if (PHAR_G(readonly) && !phar_obj->arc.archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Cannot set signature algorithm, phar is read-only"); return; } + if (phar_obj->arc.archive->is_zip) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "Cannot set signature algorithm, not possible with zip-based phar archives"); http://cvs.php.net/viewvc.cgi/php-src/ext/phar/util.c?r1=1.55.2.16&r2=1.55.2.17&diff_format=u Index: php-src/ext/phar/util.c diff -u php-src/ext/phar/util.c:1.55.2.16 php-src/ext/phar/util.c:1.55.2.17 --- php-src/ext/phar/util.c:1.55.2.16 Sat Jun 21 06:21:58 2008 +++ php-src/ext/phar/util.c Sat Jun 21 18:57:53 2008 @@ -18,11 +18,11 @@ +----------------------------------------------------------------------+ */ -/* $Id: util.c,v 1.55.2.16 2008/06/21 06:21:58 cellog Exp $ */ +/* $Id: util.c,v 1.55.2.17 2008/06/21 18:57:53 sfox Exp $ */ #include "phar_internal.h" -#ifdef PHAR_HAVE_OPENSSL +#ifdef PHAR_HAVE_OPENSSL /* OpenSSL includes */ #include <openssl/evp.h> #include <openssl/x509.h> @@ -34,11 +34,10 @@ #include <openssl/rand.h> #include <openssl/ssl.h> #include <openssl/pkcs12.h> - -#endif -#ifndef PHAR_HAVE_OPENSSL +#else static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC); #endif + #if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300 extern php_stream_wrapper php_stream_phar_wrapper; #endif @@ -257,10 +256,13 @@ phar = PHAR_G(last_phar); goto splitted; } + if (fname_len < 7 || memcmp(fname, "phar://", 7) || SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) { return phar_save_resolve_path(filename, filename_len TSRMLS_CC); } + efree(entry); + if (*filename == '.') { int try_len; @@ -790,6 +792,7 @@ } phar_set_pharfp(phar, php_stream_open_wrapper(phar->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|0, NULL) TSRMLS_CC); + if (!phar_get_pharfp(phar TSRMLS_CC)) { return FAILURE; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php