cvs: php4 /main fopen-wrappers.c
| From: | Andi Gutmans | Date: | Fri, 18 Aug 2000 23:03:49 +0000 |
| Subject: | cvs: php4 /main fopen-wrappers.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-1231@lists.php.net to get a copy of this message | ||
andi Fri Aug 18 16:03:49 2000 EDT
Modified files:
/php4/main fopen-wrappers.c
Log:
- Centralize more fopen-wrappers functionality.
Index: php4/main/fopen-wrappers.c
diff -u php4/main/fopen-wrappers.c:1.76 php4/main/fopen-wrappers.c:1.77
--- php4/main/fopen-wrappers.c:1.76 Wed Aug 16 12:26:21 2000
+++ php4/main/fopen-wrappers.c Fri Aug 18 16:03:49 2000
@@ -16,7 +16,7 @@
| Jim Winstead <jimw@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: fopen-wrappers.c,v 1.76 2000/08/16 19:26:21 andi Exp $ */
+/* $Id: fopen-wrappers.c,v 1.77 2000/08/18 23:03:49 andi Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -251,6 +251,9 @@
{
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 @@
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 @@
char *pathbuf, *ptr, *end;
char trypath[MAXPATHLEN + 1];
struct stat sb;
+ FILE *fp;
PLS_FETCH();
if (opened_path) {
@@ -407,8 +408,6 @@
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 @@
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 @@
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 @@
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 @@
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);