cvs: php4 /main php_virtual_cwd.c
| From: | Andi Gutmans | Date: | Tue, 27 Jun 2000 18:18:18 +0000 |
| Subject: | cvs: php4 /main php_virtual_cwd.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-511@lists.php.net to get a copy of this message | ||
andi Tue Jun 27 11:18:18 2000 EDT
Modified files:
/php4/main php_virtual_cwd.c
Log:
- Fix bug with VIRTUAL_DIR, .., and symlinks.
Index: php4/main/php_virtual_cwd.c
diff -u php4/main/php_virtual_cwd.c:1.58 php4/main/php_virtual_cwd.c:1.59
--- php4/main/php_virtual_cwd.c:1.58 Mon Jun 26 09:24:28 2000
+++ php4/main/php_virtual_cwd.c Tue Jun 27 11:18:18 2000
@@ -271,10 +271,22 @@
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));