diff options
author | Andi Gutmans <andi@php.net> | 2000-04-05 20:49:51 +0000 |
---|---|---|
committer | Andi Gutmans <andi@php.net> | 2000-04-05 20:49:51 +0000 |
commit | d7dc66bdbd6e33eca18e1768a464e04f76ddbbf1 (patch) | |
tree | c6ee6f9f7dd09d2163b2f7019379312c9218edc4 /main/php_virtual_cwd.c | |
parent | 875ac538fbab8113c71e41ad7d45edb6cca34533 (diff) | |
download | php-git-d7dc66bdbd6e33eca18e1768a464e04f76ddbbf1.tar.gz |
- More fixes
Diffstat (limited to 'main/php_virtual_cwd.c')
-rw-r--r-- | main/php_virtual_cwd.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/main/php_virtual_cwd.c b/main/php_virtual_cwd.c index 6f0f66f032..f809c54414 100644 --- a/main/php_virtual_cwd.c +++ b/main/php_virtual_cwd.c @@ -220,17 +220,20 @@ CWD_API int virtual_file_ex(cwd_state *state, char *path, verify_path_func verif cwd_state *old_state; int ret = 0; int copy_amount = -1; + char *free_path; + zend_bool is_absolute = 0; if (path_length == 0) return (0); - path = estrndup(path, path_length); + free_path = path = estrndup(path, path_length); old_state = (cwd_state *) malloc(sizeof(cwd_state)); CWD_STATE_COPY(old_state, state); if (IS_ABSOLUTE_PATH(path, path_length)) { copy_amount = COPY_WHEN_ABSOLUTE; + is_absolute = 1; #ifdef ZEND_WIN32 } else if(IS_SLASH(path[0])) { copy_amount = 2; @@ -239,8 +242,13 @@ CWD_API int virtual_file_ex(cwd_state *state, char *path, verify_path_func verif if (copy_amount != -1) { state->cwd = (char *) realloc(state->cwd, copy_amount + 1); - if (copy_amount) - memcpy(state->cwd, old_state->cwd, copy_amount); + if (copy_amount) { + if (is_absolute) { + memcpy(state->cwd, path, copy_amount); + } else { + memcpy(state->cwd, old_state->cwd, copy_amount); + } + } state->cwd[copy_amount] = '\0'; state->cwd_length = copy_amount; path += copy_amount; @@ -293,7 +301,7 @@ CWD_API int virtual_file_ex(cwd_state *state, char *path, verify_path_func verif free(old_state); - efree(path); + efree(free_path); return (ret); } |