mirror of
https://github.com/php/php-src.git
synced 2026-03-27 09:42:22 +01:00
- ws
This commit is contained in:
@@ -43,4 +43,3 @@ $(builddir)/phar.phar: $(builddir)/phar.php $(builddir)/phar/phar.inc $(srcdir)/
|
||||
install-pharcmd: pharcmd
|
||||
-@$(mkinstalldirs) $(INSTALL_ROOT)$(bindir)
|
||||
$(INSTALL) $(builddir)/phar.phar $(INSTALL_ROOT)$(bindir)
|
||||
|
||||
|
||||
@@ -1818,9 +1818,9 @@ woohoo:
|
||||
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 @@ int phar_open_executed_filename(char *alias, int alias_len, char **error TSRMLS_
|
||||
}
|
||||
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 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
|
||||
}
|
||||
return EOF;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
*error = NULL;
|
||||
}
|
||||
@@ -2459,6 +2459,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
|
||||
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 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
|
||||
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 @@ void phar_request_initialize(TSRMLS_D) /* {{{ */
|
||||
}
|
||||
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;
|
||||
@@ -3438,9 +3440,9 @@ PHP_MINFO_FUNCTION(phar) /* {{{ */
|
||||
*/
|
||||
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
|
||||
|
||||
@@ -1178,13 +1178,16 @@ PHP_METHOD(Phar, __construct)
|
||||
}
|
||||
|
||||
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 @@ PHP_METHOD(Phar, __construct)
|
||||
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC,
|
||||
"Phar creation or opening failed");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1262,10 +1266,12 @@ PHP_METHOD(Phar, getSupportedSignatures)
|
||||
|
||||
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 @@ static zval *phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool c
|
||||
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 @@ no_copy:
|
||||
}
|
||||
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 @@ PHP_METHOD(Phar, setAlias)
|
||||
"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 @@ PHP_METHOD(Phar, setStub)
|
||||
/* {{{ 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 @@ PHP_METHOD(Phar, setSignatureAlgorithm)
|
||||
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");
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
/* $Id$ */
|
||||
|
||||
#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 @@ char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_d
|
||||
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 @@ int phar_open_archive_fp(phar_archive_data *phar TSRMLS_DC)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user