diff options
Diffstat (limited to 'ext/phar')
-rw-r--r-- | ext/phar/phar.c | 35 | ||||
-rw-r--r-- | ext/phar/phar_internal.h | 4 | ||||
-rw-r--r-- | ext/phar/phar_object.c | 5 | ||||
-rw-r--r-- | ext/phar/util.c | 6 |
4 files changed, 22 insertions, 28 deletions
diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 7339b0eed2..99502478be 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -26,7 +26,7 @@ static void destroy_phar_data(zval *zv); ZEND_DECLARE_MODULE_GLOBALS(phar) -zend_string *(*phar_save_resolve_path)(const char *filename, size_t filename_len); +static zend_string *(*phar_save_resolve_path)(zend_string *filename); /** * set's phar->is_writeable based on the current INI value @@ -3292,41 +3292,41 @@ static size_t phar_zend_stream_fsizer(void *handle) /* {{{ */ } /* }}} */ zend_op_array *(*phar_orig_compile_file)(zend_file_handle *file_handle, int type); -#define phar_orig_zend_open zend_stream_open_function -static zend_string *phar_resolve_path(const char *filename, size_t filename_len) +static zend_string *phar_resolve_path(zend_string *filename) { - return phar_find_in_include_path((char *) filename, filename_len, NULL); + zend_string *ret = phar_find_in_include_path(ZSTR_VAL(filename), ZSTR_LEN(filename), NULL); + if (!ret) { + ret = phar_save_resolve_path(filename); + } + return ret; } static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type) /* {{{ */ { zend_op_array *res; - char *name = NULL; + zend_string *name = NULL; int failed; phar_archive_data *phar; if (!file_handle || !file_handle->filename) { return phar_orig_compile_file(file_handle, type); } - if (strstr(file_handle->filename, ".phar") && !strstr(file_handle->filename, "://")) { - if (SUCCESS == phar_open_from_filename((char*)file_handle->filename, strlen(file_handle->filename), NULL, 0, 0, &phar, NULL)) { + if (strstr(ZSTR_VAL(file_handle->filename), ".phar") && !strstr(ZSTR_VAL(file_handle->filename), "://")) { + if (SUCCESS == phar_open_from_filename(ZSTR_VAL(file_handle->filename), ZSTR_LEN(file_handle->filename), NULL, 0, 0, &phar, NULL)) { if (phar->is_zip || phar->is_tar) { - zend_file_handle f = *file_handle; + zend_file_handle f; /* zip or tar-based phar */ - spprintf(&name, 4096, "phar://%s/%s", file_handle->filename, ".phar/stub.php"); - if (SUCCESS == phar_orig_zend_open((const char *)name, &f)) { - - efree(name); - name = NULL; - + name = zend_strpprintf(4096, "phar://%s/%s", ZSTR_VAL(file_handle->filename), ".phar/stub.php"); + zend_stream_init_filename_ex(&f, name); + if (SUCCESS == zend_stream_open_function(&f)) { + zend_string_release(f.filename); f.filename = file_handle->filename; if (f.opened_path) { - efree(f.opened_path); + zend_string_release(f.opened_path); } f.opened_path = file_handle->opened_path; - f.free_filename = file_handle->free_filename; switch (file_handle->type) { case ZEND_HANDLE_STREAM: @@ -3341,7 +3341,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type) *file_handle = f; } } else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) { - zend_file_handle_dtor(file_handle); /* compressed phar */ file_handle->type = ZEND_HANDLE_STREAM; /* we do our own reading directly from the phar, don't change the next line */ @@ -3367,7 +3366,7 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type) } zend_end_try(); if (name) { - efree(name); + zend_string_release(name); } if (failed) { diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index dab3688ba4..89344a3f22 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -475,10 +475,6 @@ union _phar_entry_object { phar_entry_info *entry; }; -#ifndef PHAR_MAIN -extern zend_string *(*phar_save_resolve_path)(const char *filename, size_t filename_len); -#endif - BEGIN_EXTERN_C() #ifdef PHP_WIN32 diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 2100356d9b..f67855af18 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -247,13 +247,12 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char if (!new_op_array) { zend_hash_str_del(&EG(included_files), name, name_len); } - - zend_destroy_file_handle(&file_handle); - } else { efree(name); new_op_array = NULL; } + + zend_destroy_file_handle(&file_handle); #ifdef PHP_WIN32 efree(arch); #endif diff --git a/ext/phar/util.c b/ext/phar/util.c index 59362bbc72..4011a996ca 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -253,7 +253,7 @@ zend_string *phar_find_in_include_path(char *filename, size_t filename_len, phar } if (!zend_is_executing() || !PHAR_G(cwd)) { - return phar_save_resolve_path(filename, filename_len); + return NULL; } fname = (char*)zend_get_executed_filename(); @@ -267,7 +267,7 @@ zend_string *phar_find_in_include_path(char *filename, size_t filename_len, phar } if (fname_len < 7 || memcmp(fname, "phar://", 7) || SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0)) { - return phar_save_resolve_path(filename, filename_len); + return NULL; } efree(entry); @@ -277,7 +277,7 @@ zend_string *phar_find_in_include_path(char *filename, size_t filename_len, phar if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL)) { efree(arch); - return phar_save_resolve_path(filename, filename_len); + return NULL; } splitted: if (pphar) { |