mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix #79806: realpath() erroneously resolves link to link
After resolving reparse points, the path still may be a reparse point; in that case we have to resolve that reparse point as well.
This commit is contained in:
parent
efe6d96b45
commit
c756f82c02
3 changed files with 20 additions and 8 deletions
1
NEWS
1
NEWS
|
@ -5,6 +5,7 @@ PHP NEWS
|
||||||
- Core:
|
- Core:
|
||||||
. Fixed bug #79884 (PHP_CONFIG_FILE_PATH is meaningless). (cmb)
|
. Fixed bug #79884 (PHP_CONFIG_FILE_PATH is meaningless). (cmb)
|
||||||
. Fixed bug #77932 (File extensions are case-sensitive). (cmb)
|
. Fixed bug #77932 (File extensions are case-sensitive). (cmb)
|
||||||
|
. Fixed bug #79806 (realpath() erroneously resolves link to link). (cmb)
|
||||||
|
|
||||||
- LDAP:
|
- LDAP:
|
||||||
. Fixed memory leaks. (ptomulik)
|
. Fixed memory leaks. (ptomulik)
|
||||||
|
|
|
@ -845,6 +845,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ZEND_WIN32
|
#ifdef ZEND_WIN32
|
||||||
|
retry_reparse_point:
|
||||||
if (save) {
|
if (save) {
|
||||||
pathw = php_win32_ioutil_any_to_w(path);
|
pathw = php_win32_ioutil_any_to_w(path);
|
||||||
if (!pathw) {
|
if (!pathw) {
|
||||||
|
@ -867,7 +868,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);
|
tmp = do_alloca(len+1, use_heap);
|
||||||
memcpy(tmp, path, len+1);
|
memcpy(tmp, path, len+1);
|
||||||
|
|
||||||
retry:
|
retry_reparse_tag_cloud:
|
||||||
if(save &&
|
if(save &&
|
||||||
!(IS_UNC_PATH(path, len) && len >= 3 && path[2] != '?') &&
|
!(IS_UNC_PATH(path, len) && len >= 3 && path[2] != '?') &&
|
||||||
(dataw.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
(dataw.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
|
||||||
|
@ -928,7 +929,7 @@ retry:
|
||||||
dataw.dwFileAttributes = fileInformation.dwFileAttributes;
|
dataw.dwFileAttributes = fileInformation.dwFileAttributes;
|
||||||
CloseHandle(hLink);
|
CloseHandle(hLink);
|
||||||
(*ll)--;
|
(*ll)--;
|
||||||
goto retry;
|
goto retry_reparse_tag_cloud;
|
||||||
}
|
}
|
||||||
free_alloca(tmp, use_heap);
|
free_alloca(tmp, use_heap);
|
||||||
CloseHandle(hLink);
|
CloseHandle(hLink);
|
||||||
|
@ -1075,6 +1076,22 @@ retry:
|
||||||
free_alloca(pbuffer, use_heap_large);
|
free_alloca(pbuffer, use_heap_large);
|
||||||
free(substitutename);
|
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(isabsolute == 1) {
|
||||||
if (!((j == 3) && (path[1] == ':') && (path[2] == '\\'))) {
|
if (!((j == 3) && (path[1] == ':') && (path[2] == '\\'))) {
|
||||||
/* use_realpath is 0 in the call below coz path is absolute*/
|
/* use_realpath is 0 in the call below coz path is absolute*/
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Test realpath() with relative paths
|
Test realpath() with relative paths
|
||||||
--SKIPIF--
|
|
||||||
<?php
|
|
||||||
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
|
||||||
die('skip no symlinks on Windows');
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
$file_path = dirname(__FILE__);
|
$file_path = dirname(__FILE__);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue