mirror of
https://github.com/php/php-src.git
synced 2024-11-25 19:05:31 +08:00
- Centralize more fopen-wrappers functionality.
This commit is contained in:
parent
53a3f074ab
commit
0c57780b11
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user