pajoye                                   Sat, 29 Aug 2009 12:21:47 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=287877

Log:
- Fix #48746, mounted volume support & resolution

Bug: http://bugs.php.net/48746 (Assigned) Unable to browse directories within 
Junction Points
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c
    U   php/php-src/trunk/TSRM/tsrm_virtual_cwd.c

Modified: php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c
===================================================================
--- php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c        2009-08-29 
10:24:56 UTC (rev 287876)
+++ php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c        2009-08-29 
12:21:47 UTC (rev 287877)
@@ -670,6 +670,7 @@
                        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,17 +718,25 @@
                        }

                        if(isabsolute && rname_len > 4) {
-                               /* Skip first 4 characters if they are "\\?\" */
-                               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;
                                }
-                               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 */
@@ -740,11 +749,13 @@
                        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 {
@@ -1010,7 +1021,6 @@

        add_slash = (use_realpath != CWD_REALPATH) && path_length > 0 && 
IS_SLASH(resolved_path[path_length-1]);
        t = CWDG(realpath_cache_ttl) ? 0 : -1;
-
        path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, 
&t, use_realpath, 0, NULL TSRMLS_CC);

        if (path_length < 0) {

Modified: php/php-src/trunk/TSRM/tsrm_virtual_cwd.c
===================================================================
--- php/php-src/trunk/TSRM/tsrm_virtual_cwd.c   2009-08-29 10:24:56 UTC (rev 
287876)
+++ php/php-src/trunk/TSRM/tsrm_virtual_cwd.c   2009-08-29 12:21:47 UTC (rev 
287877)
@@ -670,6 +670,7 @@
                        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,17 +718,25 @@
                        }

                        if(isabsolute && rname_len > 4) {
-                               /* Skip first 4 characters if they are "\\?\" */
-                               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;
                                }
-                               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 */
@@ -740,11 +749,13 @@
                        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 {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to