From 0c366503a62d9685fd6829fc154c00a1979b0fe4 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Wed, 26 Aug 2009 20:44:05 +0000 Subject: [PATCH] - fix #48746, regression with file operaiton on path with junctions --- TSRM/tsrm_virtual_cwd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index 1a5afc47af..00e878707f 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -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]); -- 2.40.0