summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2000-06-27 18:18:18 +0000
committerAndi Gutmans <andi@php.net>2000-06-27 18:18:18 +0000
commiteaa2a158c88e05e3c326c0238d7f49ac16b4ed4e (patch)
tree4ee72019a8ad315356a92b90c4d214e7417d2746 /main
parent7f059e7255cc06e22c837f3f36ed6965c97452bd (diff)
downloadphp-git-eaa2a158c88e05e3c326c0238d7f49ac16b4ed4e.tar.gz
- Fix bug with VIRTUAL_DIR, .., and symlinks.
Diffstat (limited to 'main')
-rw-r--r--main/php_virtual_cwd.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/main/php_virtual_cwd.c b/main/php_virtual_cwd.c
index 2c378b760e..392f1444ad 100644
--- a/main/php_virtual_cwd.c
+++ b/main/php_virtual_cwd.c
@@ -271,10 +271,22 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
int copy_amount = -1;
char *free_path;
zend_bool is_absolute = 0;
+#ifndef ZEND_WIN32
+ char resolved_path[MAXPATHLEN];
+#endif
if (path_length == 0)
return (0);
+#ifndef ZEND_WIN32
+ if (strstr(path, "..")) {
+ /* If .. is found then we need to resolve real path as the .. code doesn't work with symlinks */
+ if (realpath(path, resolved_path)) {
+ path = resolved_path;
+ path_length = strlen(path);
+ }
+ }
+#endif
free_path = path_copy = estrndup(path, path_length);
old_state = (cwd_state *) malloc(sizeof(cwd_state));