summaryrefslogtreecommitdiff
path: root/main/main.c
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2000-08-27 19:38:18 +0000
committerSascha Schumann <sas@php.net>2000-08-27 19:38:18 +0000
commit3f969d0b84fdaf936becd990c8331679d8eab752 (patch)
tree7127ccca17b37390caa47ead756f57030e1d8325 /main/main.c
parent626fc9a7732fa07a1dc9cd861818b049c9862b21 (diff)
downloadphp-git-3f969d0b84fdaf936becd990c8331679d8eab752.tar.gz
If a SAPI module does not pass an absolute path as primary_file to
php_execute_script(), we will now change the filename to point to the absolute path.
Diffstat (limited to 'main/main.c')
-rw-r--r--main/main.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/main/main.c b/main/main.c
index 27330cffb6..8c50ca849c 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1105,9 +1105,11 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_
{
zend_file_handle *prepend_file_p, *append_file_p;
zend_file_handle prepend_file, append_file;
- char old_cwd[4096] = "";
+ char old_cwd[4096];
+ char new_path[4096] = "";
SLS_FETCH();
+ old_cwd[0] = new_path[0] = '\0';
php_hash_environment(ELS_C SLS_CC PLS_CC);
zend_activate_modules();
@@ -1147,6 +1149,13 @@ PHPAPI void php_execute_script(zend_file_handle *primary_file CLS_DC ELS_DC PLS_
if (primary_file->type == ZEND_HANDLE_FILENAME
&& primary_file->filename) {
V_GETCWD(old_cwd, sizeof(old_cwd)-1);
+
+ if (!IS_ABSOLUTE_PATH(primary_file->filename, strlen(primary_file->filename))) {
+ snprintf(new_path, sizeof(new_path), "%s%c%s", old_cwd, PHP_DIR_SEPARATOR, primary_file->filename);
+ new_path[sizeof(new_path)-1] = '\0';
+ primary_file->filename = new_path;
+ }
+
V_CHDIR_FILE(primary_file->filename);
}