1
0
mirror of https://github.com/php/php-src.git synced 2026-03-27 17:52:16 +01:00

- fix #48746, regression with file operaiton on path with junctions

This commit is contained in:
Pierre Joye
2009-08-26 20:44:05 +00:00
parent 46ba563fe1
commit 0c366503a6

View File

@@ -692,12 +692,22 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
if(pbuffer->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
rname_len = pbuffer->SymbolicLinkReparseBuffer.PrintNameLength/2;
rname_off = pbuffer->SymbolicLinkReparseBuffer.PrintNameOffset/2;
if(rname_len <= 0) {
rname_len = pbuffer->SymbolicLinkReparseBuffer.SubstituteNameLength/2;
rname_off = pbuffer->SymbolicLinkReparseBuffer.SubstituteNameOffset/2;
}
reparsetarget = pbuffer->SymbolicLinkReparseBuffer.ReparseTarget;
isabsolute = (pbuffer->SymbolicLinkReparseBuffer.Flags == 0) ? 1 : 0;
}
else if(pbuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
rname_len = pbuffer->MountPointReparseBuffer.PrintNameLength/2;
rname_off = pbuffer->MountPointReparseBuffer.PrintNameOffset/2;
if(rname_len <= 0) {
rname_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength/2;
rname_off = pbuffer->MountPointReparseBuffer.SubstituteNameOffset/2;
}
reparsetarget = pbuffer->MountPointReparseBuffer.ReparseTarget;
isabsolute = 1;
}
@@ -706,6 +716,15 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
return -1;
}
if(isabsolute && rname_len > 4) {
/* Skip first 4 characters if they are "\\?\" */
if(reparsetarget[rname_off] == L'\\' && reparsetarget[rname_off + 1] == L'\\' &&
reparsetarget[rname_off + 2] == L'?' && reparsetarget[rname_off + 3] == L'\\') {
rname_off += 4;
rname_len -= 4;
}
}
/* Convert wide string to narrow string */
for(bufindex = 0; bufindex < rname_len; bufindex++) {
*(path + bufindex) = (char)(reparsetarget[rname_off + bufindex]);