diff options
author | Dmitry Stogov <dmitry@php.net> | 2012-01-30 10:08:11 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2012-01-30 10:08:11 +0000 |
commit | ce9f1a4313dbb0d9fef5e9521c8f91bc2b7304ef (patch) | |
tree | 241a3ceb129e034b475d73e16ee510ba10ad737a | |
parent | c5bb1710bd03170ce1af409a332f80b4291e72cc (diff) | |
download | php-git-ce9f1a4313dbb0d9fef5e9521c8f91bc2b7304ef.tar.gz |
Fixed bug #51860 (Include fails with toplevel symlink to /)
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | TSRM/tsrm_virtual_cwd.c | 18 |
2 files changed, 16 insertions, 3 deletions
@@ -12,6 +12,7 @@ PHP NEWS (Dmitry, Laruence) . Fix bug #60895 (Possible invalid handler usage in windows random functions). (Pierre) + . Fixed bug #51860 (Include fails with toplevel symlink to /). (Dmitry) - Firebird Database extension (ibase): . Fixed bug #60802 (ibase_trans() gives segfault when passing params). diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index 5977029303..e734406837 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -773,6 +773,9 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i while (1) { if (len <= start) { + if (link_is_dir) { + *link_is_dir = 1; + } return start; } @@ -789,6 +792,10 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i continue; } else if (i == len - 2 && path[i] == '.' && path[i+1] == '.') { /* remove '..' and previous directory */ + is_dir = 1; + if (link_is_dir) { + *link_is_dir = 1; + } if (i - 1 <= start) { return start ? start : len; } @@ -1214,9 +1221,14 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func return 1; } memcpy(resolved_path, state->cwd, state_cwd_length); - resolved_path[state_cwd_length] = DEFAULT_SLASH; - memcpy(resolved_path + state_cwd_length + 1, path, path_length + 1); - path_length += state_cwd_length + 1; + if (resolved_path[state_cwd_length-1] == DEFAULT_SLASH) { + memcpy(resolved_path + state_cwd_length, path, path_length + 1); + path_length += state_cwd_length; + } else { + resolved_path[state_cwd_length] = DEFAULT_SLASH; + memcpy(resolved_path + state_cwd_length + 1, path, path_length + 1); + path_length += state_cwd_length + 1; + } } } else { #ifdef TSRM_WIN32 |