cvs: php4 /main fopen_wrappers.c
| From: | Andi Gutmans | Date: | Tue, 10 Jul 2001 20:38:40 +0000 |
| Subject: | cvs: php4 /main fopen_wrappers.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-6161@lists.php.net to get a copy of this message | ||
andi Tue Jul 10 16:38:40 2001 EDT
Modified files:
/php4/main fopen_wrappers.c
Log:
- Commit patch which checks for an include file in the calling scripts'
current working directory if everything else fails (include_path).
- Right now this also effects things like opening php.ini. It'll now always
check in the current working directory for php.ini. I think this doesn't
screw up todays behavior.
Index: php4/main/fopen_wrappers.c
diff -u php4/main/fopen_wrappers.c:1.118 php4/main/fopen_wrappers.c:1.119
--- php4/main/fopen_wrappers.c:1.118 Tue Jul 10 14:49:47 2001
+++ php4/main/fopen_wrappers.c Tue Jul 10 16:38:39 2001
@@ -16,7 +16,7 @@
| Jim Winstead <jimw@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: fopen_wrappers.c,v 1.118 2001/07/10 18:49:47 zeev Exp $ */
+/* $Id: fopen_wrappers.c,v 1.119 2001/07/10 20:38:39 andi Exp $ */
/* {{{ includes
*/
@@ -443,8 +443,39 @@
}
ptr = end;
}
+
efree(pathbuf);
- return NULL;
+
+ {
+ char *exec_fname;
+ int exec_fname_len;
+ char *filename_dir;
+ ELS_FETCH();
+
+ exec_fname = zend_get_executed_filename(ELS_C);
+ exec_fname_len = strlen(exec_fname);
+
+ pathbuf = (char *) emalloc(exec_fname_len+filename_length+1+1); /* Over allocate to save time */
+ memcpy(pathbuf, exec_fname, exec_fname_len+1);
+
+ while ((--exec_fname_len >= 0) && !IS_SLASH(pathbuf[exec_fname_len])) {
+ }
+ pathbuf[exec_fname_len] = DEFAULT_SLASH;
+ memcpy(&pathbuf[exec_fname_len+1], filename, filename_length+1);
+
+ fprintf(stderr,"Trying to open %s\n", pathbuf);
+
+ if (PG(safe_mode)) {
+ if (VCWD_STAT(pathbuf, &sb) == 0 && (!php_checkuid(pathbuf, mode,
CHECKUID_CHECK_MODE_PARAM))) {
+ efree(pathbuf);
+ return NULL;
+ }
+ }
+ fp = php_fopen_and_set_opened_path(pathbuf, mode, opened_path);
+ efree(pathbuf);
+ return fp;
+ }
+ return NULL; /* Not really needed anymore */
}
/* }}} */