ab5602          Mon Oct  8 02:49:27 2007 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/main       fopen_wrappers.c 
  Log:
  
  Fix for bug 41822 and 41899.  expand_filepath() will now return a relative 
path under the specific situation where getcwd() returns NULL and the file is 
  still readable.  As far as I have been able to tell, this fix only applies to 
the Solaris OS where files in directories with (--x) cannot getcwd().
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/fopen_wrappers.c?r1=1.175.2.3.2.13&r2=1.175.2.3.2.14&diff_format=u
Index: php-src/main/fopen_wrappers.c
diff -u php-src/main/fopen_wrappers.c:1.175.2.3.2.13 
php-src/main/fopen_wrappers.c:1.175.2.3.2.14
--- php-src/main/fopen_wrappers.c:1.175.2.3.2.13        Tue Jul 10 13:21:11 2007
+++ php-src/main/fopen_wrappers.c       Mon Oct  8 02:49:26 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: fopen_wrappers.c,v 1.175.2.3.2.13 2007/07/10 13:21:11 dmitry Exp $ */
+/* $Id: fopen_wrappers.c,v 1.175.2.3.2.14 2007/10/08 02:49:26 ab5602 Exp $ */
 
 /* {{{ includes
  */
@@ -604,18 +604,30 @@
 {
        cwd_state new_state;
        char cwd[MAXPATHLEN];
-       char *result;
 
        if (!filepath[0]) {
                return NULL;
        } else if (IS_ABSOLUTE_PATH(filepath, strlen(filepath))) {
                cwd[0] = '\0';
-       } else{
-               result = VCWD_GETCWD(cwd, MAXPATHLEN);
-               if (!result) {
+       } else {
+               const char *iam = SG(request_info).path_translated;
+               char *result = VCWD_GETCWD(cwd, MAXPATHLEN);
+               if (!result && (iam != filepath)) {
+                       int fdtest = -1;
+                       fdtest = VCWD_OPEN(filepath, O_RDONLY);
+                       if (fdtest != -1) {
+                               /* return a relative file path if for any 
reason 
+                                  we cannot cannot getcwd() and the requested, 
+                                  relatively referenced file is accessible */
+                               int copy_len = 
strlen(filepath)>MAXPATHLEN-1?MAXPATHLEN-1:strlen(filepath);
+                               real_path = estrndup(filepath, copy_len);
+                               return real_path;
+                           }   
+                        }
+               else {
                        cwd[0] = '\0';
+                       }
                }
-       }
 
        new_state.cwd = strdup(cwd);
        new_state.cwd_length = strlen(cwd);

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

Reply via email to