From eaa2a158c88e05e3c326c0238d7f49ac16b4ed4e Mon Sep 17 00:00:00 2001 From: Andi Gutmans Date: Tue, 27 Jun 2000 18:18:18 +0000 Subject: [PATCH] - Fix bug with VIRTUAL_DIR, .., and symlinks. --- main/php_virtual_cwd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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)); -- 2.40.0