dmitry Thu Aug 14 13:01:28 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/phar func_interceptors.c func_interceptors.h phar.c
Log:
Fixed bug #45613 Segfault when using is_file() on Apache-2.2.8
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/func_interceptors.c?r1=1.20.2.13&r2=1.20.2.14&diff_format=u
Index: php-src/ext/phar/func_interceptors.c
diff -u php-src/ext/phar/func_interceptors.c:1.20.2.13
php-src/ext/phar/func_interceptors.c:1.20.2.14
--- php-src/ext/phar/func_interceptors.c:1.20.2.13 Tue Aug 12 14:56:52 2008
+++ php-src/ext/phar/func_interceptors.c Thu Aug 14 13:01:28 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: func_interceptors.c,v 1.20.2.13 2008/08/12 14:56:52 helly Exp $ */
+/* $Id: func_interceptors.c,v 1.20.2.14 2008/08/14 13:01:28 dmitry Exp $ */
#include "phar_internal.h"
@@ -1130,6 +1130,85 @@
}
/* }}} */
+static struct _phar_orig_functions {
+ void (*orig_fopen)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_file_get_contents)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_file)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_link)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_dir)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_opendir)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_file_exists)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileperms)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileinode)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filesize)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileowner)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filegroup)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_fileatime)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filemtime)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filectime)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_filetype)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_writable)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_readable)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_is_executable)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_lstat)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_readfile)(INTERNAL_FUNCTION_PARAMETERS);
+ void (*orig_stat)(INTERNAL_FUNCTION_PARAMETERS);
+} phar_orig_functions = {NULL};
+
+void phar_save_orig_functions(TSRMLS_D) /* {{{ */
+{
+ phar_orig_functions.orig_fopen = PHAR_G(orig_fopen);
+ phar_orig_functions.orig_file_get_contents =
PHAR_G(orig_file_get_contents);
+ phar_orig_functions.orig_is_file = PHAR_G(orig_is_file);
+ phar_orig_functions.orig_is_link = PHAR_G(orig_is_link);
+ phar_orig_functions.orig_is_dir = PHAR_G(orig_is_dir);
+ phar_orig_functions.orig_opendir = PHAR_G(orig_opendir);
+ phar_orig_functions.orig_file_exists = PHAR_G(orig_file_exists);
+ phar_orig_functions.orig_fileperms = PHAR_G(orig_fileperms);
+ phar_orig_functions.orig_fileinode = PHAR_G(orig_fileinode);
+ phar_orig_functions.orig_filesize = PHAR_G(orig_filesize);
+ phar_orig_functions.orig_fileowner = PHAR_G(orig_fileowner);
+ phar_orig_functions.orig_filegroup = PHAR_G(orig_filegroup);
+ phar_orig_functions.orig_fileatime = PHAR_G(orig_fileatime);
+ phar_orig_functions.orig_filemtime = PHAR_G(orig_filemtime);
+ phar_orig_functions.orig_filectime = PHAR_G(orig_filectime);
+ phar_orig_functions.orig_filetype = PHAR_G(orig_filetype);
+ phar_orig_functions.orig_is_writable = PHAR_G(orig_is_writable);
+ phar_orig_functions.orig_is_readable = PHAR_G(orig_is_readable);
+ phar_orig_functions.orig_is_executable = PHAR_G(orig_is_executable);
+ phar_orig_functions.orig_lstat = PHAR_G(orig_lstat);
+ phar_orig_functions.orig_readfile = PHAR_G(orig_readfile);
+ phar_orig_functions.orig_stat = PHAR_G(orig_stat);
+}
+/* }}} */
+
+void phar_restore_orig_functions(TSRMLS_D) /* {{{ */
+{
+ PHAR_G(orig_fopen) = phar_orig_functions.orig_fopen;
+ PHAR_G(orig_file_get_contents) =
phar_orig_functions.orig_file_get_contents;
+ PHAR_G(orig_is_file) = phar_orig_functions.orig_is_file;
+ PHAR_G(orig_is_link) = phar_orig_functions.orig_is_link;
+ PHAR_G(orig_is_dir) = phar_orig_functions.orig_is_dir;
+ PHAR_G(orig_opendir) = phar_orig_functions.orig_opendir;
+ PHAR_G(orig_file_exists) = phar_orig_functions.orig_file_exists;
+ PHAR_G(orig_fileperms) = phar_orig_functions.orig_fileperms;
+ PHAR_G(orig_fileinode) = phar_orig_functions.orig_fileinode;
+ PHAR_G(orig_filesize) = phar_orig_functions.orig_filesize;
+ PHAR_G(orig_fileowner) = phar_orig_functions.orig_fileowner;
+ PHAR_G(orig_filegroup) = phar_orig_functions.orig_filegroup;
+ PHAR_G(orig_fileatime) = phar_orig_functions.orig_fileatime;
+ PHAR_G(orig_filemtime) = phar_orig_functions.orig_filemtime;
+ PHAR_G(orig_filectime) = phar_orig_functions.orig_filectime;
+ PHAR_G(orig_filetype) = phar_orig_functions.orig_filetype;
+ PHAR_G(orig_is_writable) = phar_orig_functions.orig_is_writable;
+ PHAR_G(orig_is_readable) = phar_orig_functions.orig_is_readable;
+ PHAR_G(orig_is_executable) = phar_orig_functions.orig_is_executable;
+ PHAR_G(orig_lstat) = phar_orig_functions.orig_lstat;
+ PHAR_G(orig_readfile) = phar_orig_functions.orig_readfile;
+ PHAR_G(orig_stat) = phar_orig_functions.orig_stat;
+}
+/* }}} */
+
/*
* Local variables:
* tab-width: 4
@@ -1138,3 +1217,4 @@
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
+
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/func_interceptors.h?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: php-src/ext/phar/func_interceptors.h
diff -u php-src/ext/phar/func_interceptors.h:1.1.2.2
php-src/ext/phar/func_interceptors.h:1.1.2.3
--- php-src/ext/phar/func_interceptors.h:1.1.2.2 Fri Aug 1 13:48:44 2008
+++ php-src/ext/phar/func_interceptors.h Thu Aug 14 13:01:28 2008
@@ -17,13 +17,15 @@
+----------------------------------------------------------------------+
*/
-/* $Id: func_interceptors.h,v 1.1.2.2 2008/08/01 13:48:44 sfox Exp $ */
+/* $Id: func_interceptors.h,v 1.1.2.3 2008/08/14 13:01:28 dmitry Exp $ */
BEGIN_EXTERN_C()
void phar_intercept_functions(TSRMLS_D);
void phar_release_functions(TSRMLS_D);
void phar_intercept_functions_init(TSRMLS_D);
void phar_intercept_functions_shutdown(TSRMLS_D);
+void phar_save_orig_functions(TSRMLS_D);
+void phar_restore_orig_functions(TSRMLS_D);
END_EXTERN_C()
/*
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.c?r1=1.370.2.38&r2=1.370.2.39&diff_format=u
Index: php-src/ext/phar/phar.c
diff -u php-src/ext/phar/phar.c:1.370.2.38 php-src/ext/phar/phar.c:1.370.2.39
--- php-src/ext/phar/phar.c:1.370.2.38 Fri Aug 1 13:48:44 2008
+++ php-src/ext/phar/phar.c Thu Aug 14 13:01:28 2008
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: phar.c,v 1.370.2.38 2008/08/01 13:48:44 sfox Exp $ */
+/* $Id: phar.c,v 1.370.2.39 2008/08/14 13:01:28 dmitry Exp $ */
#define PHAR_MAIN 1
#include "phar_internal.h"
@@ -3367,15 +3367,6 @@
};
/* }}}*/
-/* {{{ php_phar_init_globals
- */
-static void php_phar_init_globals_module(zend_phar_globals *phar_globals)
-{
- memset(phar_globals, 0, sizeof(zend_phar_globals));
- phar_globals->readonly = 1;
-}
-/* }}} */
-
static size_t phar_zend_stream_reader(void *handle, char *buf, size_t len
TSRMLS_DC) /* {{{ */
{
return php_stream_read(phar_get_pharfp((phar_archive_data*)handle
TSRMLS_CC), buf, len);
@@ -3540,35 +3531,20 @@
typedef zend_op_array* (zend_compile_t)(zend_file_handle*, int TSRMLS_DC);
typedef zend_compile_t* (compile_hook)(zend_compile_t *ptr);
-PHP_MINIT_FUNCTION(phar) /* {{{ */
+PHP_GINIT_FUNCTION(phar) /* {{{ */
{
phar_mime_type mime;
- ZEND_INIT_MODULE_GLOBALS(phar, php_phar_init_globals_module, NULL);
- REGISTER_INI_ENTRIES();
-
- phar_orig_compile_file = zend_compile_file;
- zend_compile_file = phar_compile_file;
-
-#if PHP_VERSION_ID >= 50300
- phar_save_resolve_path = zend_resolve_path;
- zend_resolve_path = phar_resolve_path;
-#else
- phar_orig_zend_open = zend_stream_open_function;
- zend_stream_open_function = phar_zend_open;
-#endif
-
- phar_object_init(TSRMLS_C);
-
- phar_intercept_functions_init(TSRMLS_C);
+ memset(phar_globals, 0, sizeof(zend_phar_globals));
+ phar_globals->readonly = 1;
- zend_hash_init(&PHAR_G(mime_types), 0, NULL, NULL, 1);
+ zend_hash_init(&phar_globals->mime_types, 0, NULL, NULL, 1);
#define PHAR_SET_MIME(mimetype, ret, fileext) \
mime.mime = mimetype; \
mime.len = sizeof((mimetype))+1; \
mime.type = ret; \
- zend_hash_add(&PHAR_G(mime_types), fileext, sizeof(fileext)-1,
(void *)&mime, sizeof(phar_mime_type), NULL); \
+ zend_hash_add(&phar_globals->mime_types, fileext,
sizeof(fileext)-1, (void *)&mime, sizeof(phar_mime_type), NULL); \
PHAR_SET_MIME("text/html", PHAR_MIME_PHPS, "phps")
PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "c")
@@ -3611,6 +3587,36 @@
PHAR_SET_MIME("image/xbm", PHAR_MIME_OTHER, "xbm")
PHAR_SET_MIME("text/xml", PHAR_MIME_OTHER, "xml")
+ phar_restore_orig_functions(TSRMLS_C);
+}
+/* }}} */
+
+PHP_GSHUTDOWN_FUNCTION(phar) /* {{{ */
+{
+ zend_hash_destroy(&phar_globals->mime_types);
+}
+/* }}} */
+
+PHP_MINIT_FUNCTION(phar) /* {{{ */
+{
+ REGISTER_INI_ENTRIES();
+
+ phar_orig_compile_file = zend_compile_file;
+ zend_compile_file = phar_compile_file;
+
+#if PHP_VERSION_ID >= 50300
+ phar_save_resolve_path = zend_resolve_path;
+ zend_resolve_path = phar_resolve_path;
+#else
+ phar_orig_zend_open = zend_stream_open_function;
+ zend_stream_open_function = phar_zend_open;
+#endif
+
+ phar_object_init(TSRMLS_C);
+
+ phar_intercept_functions_init(TSRMLS_C);
+ phar_save_orig_functions(TSRMLS_C);
+
return php_register_url_stream_wrapper("phar", &php_stream_phar_wrapper
TSRMLS_CC);
}
/* }}} */
@@ -3619,8 +3625,6 @@
{
php_unregister_url_stream_wrapper("phar" TSRMLS_CC);
- zend_hash_destroy(&PHAR_G(mime_types));
-
phar_intercept_functions_shutdown(TSRMLS_C);
if (zend_compile_file == phar_compile_file) {
@@ -3729,7 +3733,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.38 $");
+ php_info_print_table_row(2, "CVS revision", "$Revision: 1.370.2.39 $");
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");
@@ -3793,7 +3797,11 @@
PHP_RSHUTDOWN(phar),
PHP_MINFO(phar),
PHP_PHAR_VERSION,
- STANDARD_MODULE_PROPERTIES
+ PHP_MODULE_GLOBALS(phar), /* globals descriptor */
+ PHP_GINIT(phar), /* globals ctor */
+ PHP_GSHUTDOWN(phar), /* globals dtor */
+ NULL, /* post deactivate */
+ STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php