summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-07-27 15:10:11 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-07-27 15:10:22 +0200
commit85a26fef11ace24ba0d8a70fe850109cf66bdbe5 (patch)
tree86bde09ca6f994c4ee80d7790bea31d13ae03ad5
parent68aa1329eb0b669f724ebc2b56f4ffe987b59414 (diff)
parentd5b59b4303642adac91df2c93969a72bc0f5fa7d (diff)
downloadphp-git-85a26fef11ace24ba0d8a70fe850109cf66bdbe5.tar.gz
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #79806: realpath() erroneously resolves link to link
-rw-r--r--NEWS1
-rw-r--r--Zend/zend_virtual_cwd.c14
-rw-r--r--ext/standard/tests/file/realpath_basic4.phpt6
3 files changed, 13 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index 09eca0b1c8..94f7c4b62d 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ PHP NEWS
- Core:
. Fixed bug #79884 (PHP_CONFIG_FILE_PATH is meaningless). (cmb)
. Fixed bug #77932 (File extensions are case-sensitive). (cmb)
+ . Fixed bug #79806 (realpath() erroneously resolves link to link). (cmb)
06 Aug 2020, PHP 7.4.9
diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c
index e784ffc1f4..e584d608a9 100644
--- a/Zend/zend_virtual_cwd.c
+++ b/Zend/zend_virtual_cwd.c
@@ -596,6 +596,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) {
@@ -618,7 +619,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)
@@ -679,7 +680,7 @@ retry:
dataw.dwFileAttributes = fileInformation.dwFileAttributes;
CloseHandle(hLink);
(*ll)--;
- goto retry;
+ goto retry_reparse_tag_cloud;
}
free_alloca(tmp, use_heap);
CloseHandle(hLink);
@@ -826,6 +827,15 @@ retry:
free_alloca(pbuffer, use_heap_large);
free(substitutename);
+ {
+ DWORD attrs = GetFileAttributesA(path);
+ if (!isVolume && (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 47fd8040c7..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 not for Windows');
-}
-?>
--FILE--
<?php
$file_path = __DIR__;