diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-07-28 14:02:25 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-07-28 14:02:25 +0200 |
commit | 44ad2db15fe786b07ce793624885e0c43e0af897 (patch) | |
tree | 1d2a53c09dc9f75887b48f06a389cf772fa42030 | |
parent | f41bceb94ef85b962b43e82e2787c8669df50466 (diff) | |
parent | e0ebe56ebfc80bae3875b23eca4cbe0803f41e79 (diff) | |
download | php-git-44ad2db15fe786b07ce793624885e0c43e0af897.tar.gz |
Merge branch 'PHP-7.4'
* PHP-7.4:
Fix #79806: realpath() erroneously resolves link to link
-rw-r--r-- | Zend/zend_virtual_cwd.c | 21 | ||||
-rw-r--r-- | ext/standard/tests/file/realpath_basic4.phpt | 6 |
2 files changed, 19 insertions, 8 deletions
diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index ac3d6773b1..61542bfce2 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -590,6 +590,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim } #ifdef ZEND_WIN32 +retry_reparse_point: if (save) { pathw = php_win32_ioutil_any_to_w(path); if (!pathw) { @@ -612,7 +613,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim tmp = do_alloca(len+1, use_heap); memcpy(tmp, path, len+1); -retry: +retry_reparse_tag_cloud: if(save && !(IS_UNC_PATH(path, len) && len >= 3 && path[2] != '?') && (dataw.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) @@ -673,7 +674,7 @@ retry: dataw.dwFileAttributes = fileInformation.dwFileAttributes; CloseHandle(hLink); (*ll)--; - goto retry; + goto retry_reparse_tag_cloud; } free_alloca(tmp, use_heap); CloseHandle(hLink); @@ -820,6 +821,22 @@ retry: free_alloca(pbuffer, use_heap_large); free(substitutename); + { + DWORD attrs; + + FREE_PATHW() + pathw = php_win32_ioutil_any_to_w(path); + if (!pathw) { + return (size_t)-1; + } + attrs = GetFileAttributesW(pathw); + if (!isVolume && attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_REPARSE_POINT)) { + free_alloca(tmp, use_heap); + FREE_PATHW() + goto retry_reparse_point; + } + } + if(isabsolute == 1) { if (!((j == 3) && (path[1] == ':') && (path[2] == '\\'))) { /* use_realpath is 0 in the call below coz path is absolute*/ diff --git a/ext/standard/tests/file/realpath_basic4.phpt b/ext/standard/tests/file/realpath_basic4.phpt index 1af510d34a..524dde3056 100644 --- a/ext/standard/tests/file/realpath_basic4.phpt +++ b/ext/standard/tests/file/realpath_basic4.phpt @@ -1,11 +1,5 @@ --TEST-- Test realpath() with relative paths ---SKIPIF-- -<?php -if (substr(PHP_OS, 0, 3) == 'WIN') { - die('skip no symlinks on Windows'); -} -?> --FILE-- <?php $file_path = __DIR__; |