From: Pierre Joye Date: Sat, 29 Aug 2009 12:21:47 +0000 (+0000) Subject: - Fix #48746, mounted volume support & resolution X-Git-Tag: php-5.4.0alpha1~191^2~2732 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=acdd739c0bc4c1c678fc5751cce29018a50997cd;p=php - Fix #48746, mounted volume support & resolution --- diff --git a/TSRM/tsrm_virtual_cwd.c b/TSRM/tsrm_virtual_cwd.c index a2bcd78ffd..7f024ec20d 100644 --- a/TSRM/tsrm_virtual_cwd.c +++ b/TSRM/tsrm_virtual_cwd.c @@ -670,6 +670,7 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i unsigned int retlength = 0, rname_off = 0; int bufindex = 0, rname_len = 0, isabsolute = 0; wchar_t * reparsetarget; + WCHAR szVolumePathNames[MAX_PATH]; if(++(*ll) > LINK_MAX) { return -1; @@ -717,13 +718,21 @@ 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 "\\?\" */ - 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; - } - if(reparsetarget[rname_off] == L'\\' && reparsetarget[rname_off + 1] == L'?' && + /* 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); + } 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'\\') { rname_off += 4; rname_len -= 4; @@ -740,11 +749,13 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i j = bufindex; if(isabsolute == 1) { - /* use_realpath is 0 in the call below coz path is absolute*/ - j = tsrm_realpath_r(path, 0, j, ll, t, 0, is_dir, &directory TSRMLS_CC); - if(j < 0) { - tsrm_free_alloca(tmp, use_heap); - return -1; + if (!((j == 3) && (path[1] == ':') && (path[2] == '\\'))) { + /* use_realpath is 0 in the call below coz path is absolute*/ + j = tsrm_realpath_r(path, 0, j, ll, t, 0, is_dir, &directory TSRMLS_CC); + if(j < 0) { + tsrm_free_alloca(tmp, use_heap); + return -1; + } } } else {