diff options
author | Anatol Belski <ab@php.net> | 2013-10-17 10:40:43 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2013-10-17 10:40:43 +0200 |
commit | cf6ab0e915f95f01a8db1ce7daf70ed36cf49c66 (patch) | |
tree | c4fd681e0b62ad67d2b2ef9101c5e59cae8f0bc2 /main | |
parent | e30b2aae5ad93405eee19bca6125ea872f409c82 (diff) | |
download | php-git-cf6ab0e915f95f01a8db1ce7daf70ed36cf49c66.tar.gz |
applied and fixed the original patch
initial work on the patch import done
Diffstat (limited to 'main')
-rw-r--r-- | main/SAPI.c | 4 | ||||
-rw-r--r-- | main/fopen_wrappers.c | 6 | ||||
-rw-r--r-- | main/main.c | 16 | ||||
-rw-r--r-- | main/php_open_temporary_file.c | 10 | ||||
-rw-r--r-- | main/streams/plain_wrapper.c | 2 |
5 files changed, 17 insertions, 21 deletions
diff --git a/main/SAPI.c b/main/SAPI.c index 8ee7649648..c9ba5d5dce 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -91,8 +91,6 @@ SAPI_API void sapi_startup(sapi_module_struct *sf) sapi_globals_ctor(&sapi_globals); #endif - virtual_cwd_startup(); /* Could use shutdown to free the main cwd but it would just slow it down for CGI */ - #ifdef PHP_WIN32 tsrm_win32_startup(); #endif @@ -110,8 +108,6 @@ SAPI_API void sapi_shutdown(void) reentrancy_shutdown(); - virtual_cwd_shutdown(); - #ifdef PHP_WIN32 tsrm_win32_shutdown(); #endif diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 1d99a4e20e..6722798598 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -791,11 +791,11 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co } } - new_state.cwd = strdup(cwd); + new_state.cwd = estrdup(cwd); new_state.cwd_length = strlen(cwd); if (virtual_file_ex(&new_state, filepath, NULL, realpath_mode TSRMLS_CC)) { - free(new_state.cwd); + efree(new_state.cwd); return NULL; } @@ -806,7 +806,7 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co } else { real_path = estrndup(new_state.cwd, new_state.cwd_length); } - free(new_state.cwd); + efree(new_state.cwd); return real_path; } diff --git a/main/main.c b/main/main.c index 1cc842b212..2d018a7467 100644 --- a/main/main.c +++ b/main/main.c @@ -1816,6 +1816,9 @@ void php_request_shutdown(void *dummy) sapi_deactivate(TSRMLS_C); } zend_end_try(); + /* 9.5 free virtual CWD memory */ + virtual_cwd_deactivate(TSRMLS_C); + /* 10. Destroy stream hashes */ zend_try { php_shutdown_stream_hashes(TSRMLS_C); @@ -2243,9 +2246,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod } #endif -#ifdef ZTS zend_post_startup(TSRMLS_C); -#endif module_initialized = 1; @@ -2315,6 +2316,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod shutdown_memory_manager(1, 0 TSRMLS_CC); zend_interned_strings_snapshot(TSRMLS_C); + virtual_cwd_activate(TSRMLS_C); /* we're done */ return retval; @@ -2410,14 +2412,13 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC) volatile int old_cwd_fd = -1; #else char *old_cwd; - ALLOCA_FLAG(use_heap) #endif int retval = 0; EG(exit_status) = 0; #ifndef HAVE_BROKEN_GETCWD # define OLD_CWD_SIZE 4096 - old_cwd = do_alloca(OLD_CWD_SIZE, use_heap); + old_cwd = emalloc(OLD_CWD_SIZE); old_cwd[0] = '\0'; #endif @@ -2498,7 +2499,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC) if (old_cwd[0] != '\0') { php_ignore_value(VCWD_CHDIR(old_cwd)); } - free_alloca(old_cwd, use_heap); + efree(old_cwd); #endif return retval; } @@ -2509,11 +2510,10 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC) PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval **ret TSRMLS_DC) { char *old_cwd; - ALLOCA_FLAG(use_heap) EG(exit_status) = 0; #define OLD_CWD_SIZE 4096 - old_cwd = do_alloca(OLD_CWD_SIZE, use_heap); + old_cwd = emalloc(OLD_CWD_SIZE); old_cwd[0] = '\0'; zend_try { @@ -2536,7 +2536,7 @@ PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval **ret php_ignore_value(VCWD_CHDIR(old_cwd)); } - free_alloca(old_cwd, use_heap); + efree(old_cwd); return EG(exit_status); } /* }}} */ diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c index 054d497be6..8315297738 100644 --- a/main/php_open_temporary_file.c +++ b/main/php_open_temporary_file.c @@ -124,11 +124,11 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char ** cwd[0] = '\0'; } - new_state.cwd = strdup(cwd); + new_state.cwd = estrdup(cwd); new_state.cwd_length = strlen(cwd); if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)) { - free(new_state.cwd); + efree(new_state.cwd); return -1; } @@ -140,7 +140,7 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char ** if (spprintf(&opened_path, 0, "%s%s%sXXXXXX", new_state.cwd, trailing_slash, pfx) >= MAXPATHLEN) { efree(opened_path); - free(new_state.cwd); + efree(new_state.cwd); return -1; } @@ -151,7 +151,7 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char ** * which means that opening it will fail... */ if (VCWD_CHMOD(opened_path, 0600)) { efree(opened_path); - free(new_state.cwd); + efree(new_state.cwd); return -1; } fd = VCWD_OPEN_MODE(opened_path, open_flags, 0600); @@ -170,7 +170,7 @@ static int php_do_open_temporary_file(const char *path, const char *pfx, char ** } else { *opened_path_p = opened_path; } - free(new_state.cwd); + efree(new_state.cwd); return fd; } /* }}} */ diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 949b827679..4dbf6889d7 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -1436,7 +1436,7 @@ not_relative_path: php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", cwd, filename, MAXPATHLEN); } - free(cwd); + efree(cwd); if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir(trypath TSRMLS_CC)) { return NULL; |