diff options
author | Andi Gutmans <andi@php.net> | 2000-08-18 23:03:49 +0000 |
---|---|---|
committer | Andi Gutmans <andi@php.net> | 2000-08-18 23:03:49 +0000 |
commit | 0c57780b11dd8cfefb6b60fde840fa772e213a8b (patch) | |
tree | dcc67b2c264153114564ece27641e71d0208ad73 | |
parent | 53a3f074ab14fdbacdfa23a5b567fd0afde46a59 (diff) | |
download | php-git-0c57780b11dd8cfefb6b60fde840fa772e213a8b.tar.gz |
- Centralize more fopen-wrappers functionality.
-rw-r--r-- | main/fopen_wrappers.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 5c3ec5e752..58e98e508c 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -251,6 +251,9 @@ FILE *php_fopen_and_set_opened_path(const char *path, char *mode, char **opened_ { FILE *fp; + if (php_check_open_basedir((char *)path)) { + return NULL; + } fp = V_FOPEN(path, mode); if (fp && opened_path) { *opened_path = expand_filepath(path,NULL); @@ -280,9 +283,6 @@ PHPAPI FILE *php_fopen_wrapper(char *path, char *mode, int options, int *issock, if (options & ENFORCE_SAFE_MODE && PG(safe_mode) && (!php_checkuid(path, mode, 0))) { return NULL; } - if (php_check_open_basedir(path)) { - return NULL; - } return php_fopen_and_set_opened_path(path, mode, opened_path); } } @@ -396,6 +396,7 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char ** char *pathbuf, *ptr, *end; char trypath[MAXPATHLEN + 1]; struct stat sb; + FILE *fp; PLS_FETCH(); if (opened_path) { @@ -407,8 +408,6 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char ** if (PG(safe_mode) && (!php_checkuid(filename, mode, 0))) { return NULL; } - if (php_check_open_basedir(filename)) return NULL; - return php_fopen_and_set_opened_path(filename, mode, opened_path); } /* Absolute path open - prepend document_root in safe mode */ @@ -426,12 +425,8 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char ** if (!php_checkuid(trypath, mode, 0)) { return NULL; } - if (php_check_open_basedir(trypath)) return NULL; return php_fopen_and_set_opened_path(filename, mode, opened_path); } else { - if (php_check_open_basedir(filename)) { - return NULL; - } return php_fopen_and_set_opened_path(filename, mode, opened_path); } } @@ -439,9 +434,6 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char ** if (PG(safe_mode) && (!php_checkuid(filename, mode, 0))) { return NULL; } - if (php_check_open_basedir(filename)) { - return NULL; - } return php_fopen_and_set_opened_path(filename, mode, opened_path); } pathbuf = estrdup(path); @@ -465,9 +457,10 @@ PHPAPI FILE *php_fopen_with_path(char *filename, char *mode, char *path, char ** return NULL; } } - if (!php_check_open_basedir(trypath)) { + fp = php_fopen_and_set_opened_path(trypath, mode, opened_path); + if (fp) { efree(pathbuf); - return php_fopen_and_set_opened_path(trypath, mode, opened_path); + return fp; } ptr = end; } @@ -1014,11 +1007,7 @@ static FILE *php_fopen_url_wrapper(const char *path, char *mode, int options, in if (options & ENFORCE_SAFE_MODE && PG(safe_mode) && (!php_checkuid(path, mode, 0))) { fp = NULL; } else { - if (php_check_open_basedir((char *) path)) { - 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); } } return (fp); |