Skip to content

Commit

Permalink
Revert "Fix #79806: realpath() erroneously resolves link to link"
Browse files Browse the repository at this point in the history
This reverts commit d5b59b4.
  • Loading branch information
cmb69 committed Jul 27, 2020
1 parent d5b59b4 commit 1aeff52
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
1 change: 0 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ 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)

?? ??? ????, PHP 7.3.21

Expand Down
14 changes: 2 additions & 12 deletions Zend/zend_virtual_cwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,6 @@ 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) {
Expand All @@ -868,7 +867,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_reparse_tag_cloud:
retry:
if(save &&
!(IS_UNC_PATH(path, len) && len >= 3 && path[2] != '?') &&
(dataw.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
Expand Down Expand Up @@ -929,7 +928,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
dataw.dwFileAttributes = fileInformation.dwFileAttributes;
CloseHandle(hLink);
(*ll)--;
goto retry_reparse_tag_cloud;
goto retry;
}
free_alloca(tmp, use_heap);
CloseHandle(hLink);
Expand Down Expand Up @@ -1076,15 +1075,6 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
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*/
Expand Down
6 changes: 6 additions & 0 deletions ext/standard/tests/file/realpath_basic4.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
--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 = dirname(__FILE__);
Expand Down

0 comments on commit 1aeff52

Please sign in to comment.