tony2001                Fri Jun  1 13:35:23 2007 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/standard/tests/general_functions       bug41518.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/main       fopen_wrappers.c 
  Log:
  MFH: fix #41518 (file_exists() warns of open_basedir restriction on 
non-existent file)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.748&r2=1.2027.2.547.2.749&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.748 php-src/NEWS:1.2027.2.547.2.749
--- php-src/NEWS:1.2027.2.547.2.748     Fri Jun  1 10:04:05 2007
+++ php-src/NEWS        Fri Jun  1 13:35:23 2007
@@ -1,6 +1,8 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2007, PHP 5.2.4
+- Fixed bug #41518 (file_exists() warns of open_basedir restriction on 
+  non-existent file). (Tony)
 - Fixed bug #39330 (apache2handler does not call shutdown actions before 
   apache child die). (isk at ecommerce dot com, Gopal, Tony)
 
http://cvs.php.net/viewvc.cgi/php-src/main/fopen_wrappers.c?r1=1.175.2.3.2.11&r2=1.175.2.3.2.12&diff_format=u
Index: php-src/main/fopen_wrappers.c
diff -u php-src/main/fopen_wrappers.c:1.175.2.3.2.11 
php-src/main/fopen_wrappers.c:1.175.2.3.2.12
--- php-src/main/fopen_wrappers.c:1.175.2.3.2.11        Wed Apr 18 11:58:40 2007
+++ php-src/main/fopen_wrappers.c       Fri Jun  1 13:35:23 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: fopen_wrappers.c,v 1.175.2.3.2.11 2007/04/18 11:58:40 dmitry Exp $ */
+/* $Id: fopen_wrappers.c,v 1.175.2.3.2.12 2007/06/01 13:35:23 tony2001 Exp $ */
 
 /* {{{ includes
  */
@@ -172,8 +172,8 @@
                        }
                }
 
+               resolved_name_len = strlen(resolved_name);
                if (path_tmp[path_len - 1] == PHP_DIR_SEPARATOR) {
-                       resolved_name_len = strlen(resolved_name);
                        if (resolved_name[resolved_name_len - 1] != 
PHP_DIR_SEPARATOR) {
                                resolved_name[resolved_name_len] = 
PHP_DIR_SEPARATOR;
                                resolved_name[++resolved_name_len] = '\0';
@@ -189,6 +189,16 @@
                        /* File is in the right directory */
                        return 0;
                } else {
+                       /* /openbasedir/ and /openbasedir are the same 
directory */
+                       if (resolved_basedir_len == (resolved_name_len + 1) && 
resolved_basedir[resolved_basedir_len - 1] == PHP_DIR_SEPARATOR) {
+#if defined(PHP_WIN32) || defined(NETWARE)
+                               if (strncasecmp(resolved_basedir, 
resolved_name, resolved_name_len) == 0) {
+#else
+                               if (strncmp(resolved_basedir, resolved_name, 
resolved_name_len) == 0) {
+#endif
+                                       return 0;
+                               }
+                       }
                        return -1;
                }
        } else {

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/bug41518.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/general_functions/bug41518.phpt
+++ php-src/ext/standard/tests/general_functions/bug41518.phpt
--TEST--
Bug #41518 (file_exists() warns of open_basedir restriction on non-existent 
file)
--SKIPIF--
<?php
/* let's use /tmp here */
$tmp_dir = "/tmp";
if (!is_dir($tmp_dir) || realpath($tmp_dir) !== $tmp_dir) {
        die("skip");
}
?>
--INI--
open_basedir=/tmp/
--FILE--
<?php

$tmp_dir = "/tmp";
$tmp_file = $tmp_dir."/bug41418.tmp";

touch($tmp_file);
var_dump(file_exists($tmp_file)); //exists
var_dump(file_exists($tmp_file."nosuchfile")); //doesn't exist

echo "Done\n";
?>
--EXPECTF--     
bool(true)
bool(false)
Done

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

Reply via email to