summaryrefslogtreecommitdiff
path: root/TSRM/tsrm_virtual_cwd.c
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2009-09-01 17:50:59 +0000
committerPierre Joye <pajoye@php.net>2009-09-01 17:50:59 +0000
commitb6882eddf6bb3248a795e47106942b6b3b33cef7 (patch)
tree9d9f594e56d0dbfbc497b3a75eaff9585f15942f /TSRM/tsrm_virtual_cwd.c
parent12a7305e2194690350f470f2e92817f53bfb8cb3 (diff)
downloadphp-git-b6882eddf6bb3248a795e47106942b6b3b33cef7.tar.gz
- #48746, revert previous about volume. Fix volume support to allow all mounted points (with or without drives)
Diffstat (limited to 'TSRM/tsrm_virtual_cwd.c')
-rw-r--r--TSRM/tsrm_virtual_cwd.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c
index 7a2153ab42..0852e9ab24 100644
--- a/TSRM/tsrm_virtual_cwd.c
+++ b/TSRM/tsrm_virtual_cwd.c
@@ -671,6 +671,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
int bufindex = 0, rname_len = 0, isabsolute = 0;
wchar_t * reparsetarget;
WCHAR szVolumePathNames[MAX_PATH];
+ BOOL isVolume = FALSE;
if(++(*ll) > LINK_MAX) {
return -1;
@@ -718,35 +719,36 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
}
if(isabsolute && rname_len > 4) {
- /* Skip first 4 characters if they are "\\?\" and fetch the drive name */
- if ((reparsetarget[rname_off] == L'\\' && reparsetarget[rname_off + 1] == L'\\' &&
- reparsetarget[rname_off + 2] == L'?' && reparsetarget[rname_off + 3] == L'\\')) {
- BOOL res;
-
- res = GetVolumePathNameW(reparsetarget, szVolumePathNames, MAX_PATH);
- if (!res) {
- return -1;
- }
- reparsetarget = szVolumePathNames;
- rname_off = 0;
- rname_len = wcslen(szVolumePathNames);
+ /* Do not resolve volumes (for now). A mounted point can
+ target a volume without a drive, it is not certain that
+ all IO functions we use in php and its deps support
+ path with volume GUID instead of the DOS way, like:
+ d:\test\mnt\foo
+ \\?\Volume{62d1c3f8-83b9-11de-b108-806e6f6e6963}\foo
+ */
+ if (wcsncmp(reparsetarget, L"\\??\\Volume{",11) == 0
+ || wcsncmp(reparsetarget, L"\\\\?\\Volume{",11) == 0) {
+ isVolume = TRUE;
} else
- /* 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'\\') {
+ /* do not use the \??\ and \\?\ prefix*/
+ if (wcsncmp(reparsetarget, L"\\??\\", 4) == 0
+ || wcsncmp(reparsetarget, L"\\\\?\\", 4) == 0) {
rname_off += 4;
rname_len -= 4;
}
}
+ if (!isVolume) {
+ /* Convert wide string to narrow string */
+ for(bufindex = 0; bufindex < rname_len; bufindex++) {
+ *(path + bufindex) = (char)(reparsetarget[rname_off + bufindex]);
+ }
- /* Convert wide string to narrow string */
- for(bufindex = 0; bufindex < rname_len; bufindex++) {
- *(path + bufindex) = (char)(reparsetarget[rname_off + bufindex]);
+ *(path + bufindex) = 0;
+ j = bufindex;
+ } else {
+ j = rname_len + 1;
}
-
- *(path + bufindex) = 0;
tsrm_free_alloca(pbuffer, use_heap_large);
- j = bufindex;
if(isabsolute == 1) {
if (!((j == 3) && (path[1] == ':') && (path[2] == '\\'))) {