Skip to content

Commit 848e24f

Browse files
committed
Fix #80258: Windows Deduplication Enabled, randon permission errors
A recent bug fix regarding symlinks claimed: > After resolving reparse points, the path still may be a reparse > point; in that case we have to resolve that reparse point as well. While that is basically correct, some reparse points may point to inaccessible system folders (e.g. `IO_REPARSE_TAG_DEDUP` points to "\System Volume Information"). Since we don't know details about arbitrary reparse points, and are mainly interested in nested symlinks, we take a step back, and only resolve `IO_REPARSE_TAG_SYMLINK` for now. Close phpGH-6354.
1 parent 2be2707 commit 848e24f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
- Core:
66
. Fixed bug #80280 (ADD_EXTENSION_DEP() fails for ext/standard and ext/date).
77
(cmb)
8+
. Fixed bug #80258 (Windows Deduplication Enabled, randon permission errors).
9+
(cmb)
810

911
- IMAP:
1012
. Fixed bug #64076 (imap_sort() does not return FALSE on failure). (cmb)

Zend/zend_virtual_cwd.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ CWD_API realpath_cache_bucket** realpath_cache_get_buckets(void)
741741
static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, time_t *t, int use_realpath, int is_dir, int *link_is_dir) /* {{{ */
742742
{
743743
size_t i, j;
744-
int directory = 0, save;
744+
int directory = 0, save, may_retry_reparse_point;
745745
#ifdef ZEND_WIN32
746746
WIN32_FIND_DATAW dataw;
747747
HANDLE hFind = INVALID_HANDLE_VALUE;
@@ -846,6 +846,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
846846

847847
#ifdef ZEND_WIN32
848848
retry_reparse_point:
849+
may_retry_reparse_point = 0;
849850
if (save) {
850851
pathw = php_win32_ioutil_any_to_w(path);
851852
if (!pathw) {
@@ -940,6 +941,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
940941
CloseHandle(hLink);
941942

942943
if(pbuffer->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
944+
may_retry_reparse_point = 1;
943945
reparsetarget = pbuffer->SymbolicLinkReparseBuffer.ReparseTarget;
944946
isabsolute = (pbuffer->SymbolicLinkReparseBuffer.Flags == 0) ? 1 : 0;
945947
#if VIRTUAL_CWD_DEBUG
@@ -1076,7 +1078,7 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
10761078
free_alloca(pbuffer, use_heap_large);
10771079
free(substitutename);
10781080

1079-
{
1081+
if (may_retry_reparse_point) {
10801082
DWORD attrs;
10811083

10821084
FREE_PATHW()

0 commit comments

Comments
 (0)