summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/fopen_wrappers.c59
-rw-r--r--main/fopen_wrappers.h10
-rw-r--r--main/main.c3
-rw-r--r--main/php_ini.c2
4 files changed, 34 insertions, 40 deletions
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index b3ecfcbfa3..d009dbbf44 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -82,15 +82,12 @@
#endif
/* }}} */
-typedef FILE * (*php_fopen_url_wrapper_t) (const char *, char *, int, int *, int *, char **) ;
-
-static FILE *php_fopen_url_wrapper(const char *, char *, int, int *, int *, char **);
-
-HashTable fopen_url_wrappers_hash;
+static FILE *php_fopen_url_wrapper(const char *, char *, int, int *, int *, char ** TSRMLS_DC);
+static HashTable fopen_url_wrappers_hash;
/* {{{ php_register_url_wrapper
*/
-PHPAPI int php_register_url_wrapper(char *protocol, FILE * (*wrapper)(char *path, char *mode, int options, int *issock, int *socketd, char **opened_path) TSRMLS_DC)
+PHPAPI int php_register_url_wrapper(char *protocol, php_fopen_url_wrapper_t wrapper TSRMLS_DC)
{
if(PG(allow_url_fopen)) {
return zend_hash_add(&fopen_url_wrappers_hash, protocol, strlen(protocol), &wrapper, sizeof(wrapper), NULL);
@@ -226,10 +223,9 @@ PHPAPI int php_check_open_basedir(char *path TSRMLS_DC)
/* {{{ php_fopen_and_set_opened_path
*/
-static FILE *php_fopen_and_set_opened_path(const char *path, char *mode, char **opened_path)
+static FILE *php_fopen_and_set_opened_path(const char *path, char *mode, char **opened_path TSRMLS_DC)
{
FILE *fp;
- TSRMLS_FETCH();
if (php_check_open_basedir((char *)path TSRMLS_CC)) {
return NULL;
@@ -244,43 +240,42 @@ static FILE *php_fopen_and_set_opened_path(const char *path, char *mode, char **
/* {{{ php_fopen_wrapper
*/
-PHPAPI FILE *php_fopen_wrapper(char *path, char *mode, int options, int *issock, int *socketd, char **opened_path)
+PHPAPI FILE *php_fopen_wrapper(char *path, char *mode, int options, int *issock, int *socketd, char **opened_path TSRMLS_DC)
{
- TSRMLS_FETCH();
-
- if(!path) return NULL;
- if(!*path) return NULL;
-
if (opened_path) {
*opened_path = NULL;
}
+ if(!path || !*path) {
+ return NULL;
+ }
+
+
if(PG(allow_url_fopen)) {
if (!(options & IGNORE_URL)) {
- return php_fopen_url_wrapper(path, mode, options, issock, socketd, opened_path);
+ return php_fopen_url_wrapper(path, mode, options, issock, socketd, opened_path TSRMLS_CC);
}
}
if (options & USE_PATH && PG(include_path) != NULL) {
- return php_fopen_with_path(path, mode, PG(include_path), opened_path);
+ return php_fopen_with_path(path, mode, PG(include_path), opened_path TSRMLS_CC);
} else {
if (options & ENFORCE_SAFE_MODE && PG(safe_mode) && (!php_checkuid(path, mode, CHECKUID_CHECK_MODE_PARAM))) {
return NULL;
}
- return php_fopen_and_set_opened_path(path, mode, opened_path);
+ return php_fopen_and_set_opened_path(path, mode, opened_path TSRMLS_CC);
}
}
/* }}} */
/* {{{ php_fopen_primary_script
*/
-PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle)
+PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC)
{
FILE *fp;
struct stat st;
char *path_info, *filename;
int length;
- TSRMLS_FETCH();
filename = SG(request_info).path_translated;
path_info = SG(request_info).request_uri;
@@ -375,7 +370,7 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle)
* Tries to open a file with a PATH-style list of directories.
* If the filename starts with "." or "/", the path is ignored.
*/
-PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **opened_path)
+PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **opened_path TSRMLS_DC)
{
char *pathbuf, *ptr, *end;
char *exec_fname;
@@ -388,7 +383,6 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **
int filename_length;
int safe_mode_include_dir_length;
int exec_fname_length;
- TSRMLS_FETCH();
if (opened_path) {
*opened_path = NULL;
@@ -405,7 +399,7 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **
if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
return NULL;
}
- return php_fopen_and_set_opened_path(filename, mode, opened_path);
+ return php_fopen_and_set_opened_path(filename, mode, opened_path TSRMLS_CC);
}
/*
@@ -429,7 +423,7 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **
#endif
{
/* absolute path matches safe_mode_include_dir */
- fp = php_fopen_and_set_opened_path(trypath, mode, opened_path);
+ fp = php_fopen_and_set_opened_path(trypath, mode, opened_path TSRMLS_CC);
if (fp) {
return fp;
}
@@ -438,14 +432,14 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **
if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
return NULL;
}
- return php_fopen_and_set_opened_path(filename, mode, opened_path);
+ return php_fopen_and_set_opened_path(filename, mode, opened_path TSRMLS_CC);
}
if (!path || (path && !*path)) {
if (PG(safe_mode) && (!php_checkuid(filename, mode, CHECKUID_CHECK_MODE_PARAM))) {
return NULL;
}
- return php_fopen_and_set_opened_path(filename, mode, opened_path);
+ return php_fopen_and_set_opened_path(filename, mode, opened_path TSRMLS_CC);
}
/* check in provided path */
@@ -491,7 +485,7 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **
#endif
{
/* trypath is in safe_mode_include_dir */
- fp = php_fopen_and_set_opened_path(trydir, mode, opened_path);
+ fp = php_fopen_and_set_opened_path(trydir, mode, opened_path TSRMLS_CC);
if (fp) {
efree(pathbuf);
return fp;
@@ -504,7 +498,7 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **
return NULL;
}
}
- fp = php_fopen_and_set_opened_path(trypath, mode, opened_path);
+ fp = php_fopen_and_set_opened_path(trypath, mode, opened_path TSRMLS_CC);
if (fp) {
efree(pathbuf);
return fp;
@@ -519,14 +513,13 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **
/* {{{ php_fopen_url_wrapper
*/
-static FILE *php_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd, char **opened_path)
+static FILE *php_fopen_url_wrapper(const char *path, char *mode, int options, int *issock, int *socketd, char **opened_path TSRMLS_DC)
{
FILE *fp = NULL;
const char *p;
const char *protocol=NULL;
int n=0;
-
for (p=path; isalnum((int)*p); p++) {
n++;
}
@@ -542,13 +535,11 @@ static FILE *php_fopen_url_wrapper(const char *path, char *mode, int options, in
protocol=NULL;
}
if (wrapper) {
- return (*wrapper)(path, mode, options, issock, socketd, opened_path);
+ return (*wrapper)(path, mode, options, issock, socketd, opened_path TSRMLS_CC);
}
}
if (!protocol || !strncasecmp(protocol, "file",n)){
- TSRMLS_FETCH();
-
*issock = 0;
if(protocol) {
@@ -562,12 +553,12 @@ static FILE *php_fopen_url_wrapper(const char *path, char *mode, int options, in
}
if (options & USE_PATH) {
- fp = php_fopen_with_path((char *) path, mode, PG(include_path), opened_path);
+ fp = php_fopen_with_path((char *) path, mode, PG(include_path), opened_path TSRMLS_CC);
} else {
if (options & ENFORCE_SAFE_MODE && PG(safe_mode) && (!php_checkuid(path, mode, CHECKUID_CHECK_MODE_PARAM))) {
fp = NULL;
} else {
- fp = php_fopen_and_set_opened_path(path, mode, opened_path);
+ fp = php_fopen_and_set_opened_path(path, mode, opened_path TSRMLS_CC);
}
}
return (fp);
diff --git a/main/fopen_wrappers.h b/main/fopen_wrappers.h
index 040dae6cb6..079156be06 100644
--- a/main/fopen_wrappers.h
+++ b/main/fopen_wrappers.h
@@ -64,15 +64,17 @@
#define IS_SOCKET 1
#define BAD_URL 2
-PHPAPI FILE *php_fopen_wrapper(char *filename, char *mode, int options, int *issock, int *socketd, char **opened_path);
+typedef FILE *(*php_fopen_url_wrapper_t)(const char *, char *, int, int *, int *, char ** TSRMLS_DC);
-PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle);
+PHPAPI FILE *php_fopen_wrapper(char *filename, char *mode, int options, int *issock, int *socketd, char **opened_path TSRMLS_DC);
+
+PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC);
PHPAPI char *expand_filepath(const char *filepath, char *real_path);
PHPAPI int php_check_open_basedir(char *path TSRMLS_DC);
PHPAPI int php_check_specific_open_basedir(char *basedir, char *path TSRMLS_DC);
-PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **opened_path);
+PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char **opened_path TSRMLS_DC);
PHPAPI int php_is_url(char *path);
PHPAPI char *php_strip_url_passwd(char *path);
@@ -80,7 +82,7 @@ PHPAPI char *php_strip_url_passwd(char *path);
int php_init_fopen_wrappers(TSRMLS_D);
int php_shutdown_fopen_wrappers(TSRMLS_D);
-PHPAPI int php_register_url_wrapper(char *protocol, FILE * (*wrapper)(char *path, char *mode, int options, int *issock, int *socketd, char **opened_path) TSRMLS_DC);
+PHPAPI int php_register_url_wrapper(char *protocol, php_fopen_url_wrapper_t wrapper TSRMLS_DC);
PHPAPI int php_unregister_url_wrapper(char *protocol TSRMLS_DC);
#endif
diff --git a/main/main.c b/main/main.c
index 87bf427aad..eff65d5f88 100644
--- a/main/main.c
+++ b/main/main.c
@@ -496,9 +496,10 @@ static FILE *php_fopen_wrapper_for_zend(const char *filename, char **opened_path
int issock=0, socketd=0;
int old_chunk_size;
FILE *retval;
+ TSRMLS_FETCH();
old_chunk_size = php_sock_set_def_chunk_size(1);
- retval=php_fopen_wrapper((char *) filename, "rb", USE_PATH|IGNORE_URL_WIN, &issock, &socketd, opened_path);
+ retval=php_fopen_wrapper((char *) filename, "rb", USE_PATH|IGNORE_URL_WIN, &issock, &socketd, opened_path TSRMLS_CC);
php_sock_set_def_chunk_size(old_chunk_size);
if (issock) {
diff --git a/main/php_ini.c b/main/php_ini.c
index d47dcac226..460b7373ea 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -251,7 +251,7 @@ int php_init_config(char *php_ini_path_override)
PG(safe_mode) = 0;
PG(open_basedir) = NULL;
- fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path);
+ fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
if (free_ini_search_path) {
efree(php_ini_search_path);
}