php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #39296 is_readable is raising a warning when the file or dir is outside open_basedir
Submitted: 2006-10-29 09:52 UTC Modified: 2007-08-17 12:21 UTC
Votes:2
Avg. Score:2.0 ± 1.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: judas dot iscariote at gmail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5CVS-2006-10-29 (CVS) OS: Linux
Private report: No CVE-ID: None
 [2006-10-29 09:52 UTC] judas dot iscariote at gmail dot com
Description:
------------
is_readable is raising and open_basedir warrning when the file/dir is not in open_basedir.


this is not expected  or at least is not mentioned in the documentation.


Reproduce code:
---------------
php  -d display_errors=1 -dopen_basedir=`pwd` -r 'var_dump(is_readable("/tmp"));'

Expected result:
----------------
a silent 

bool(false)

as stated on the documentation.



Actual result:
--------------
Warning: is_readable(): open_basedir restriction in effect. File(/tmp) is not within the allowed path(s):
bool(false)



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-29 18:00 UTC] phpbugs at thequod dot de
Has this changed since 5.1 or 4.x?
 [2006-10-29 23:51 UTC] judas dot iscariote at gmail dot com
it is silent in 4_4 , 4.3.9 this annoyance affects the whole stat() family.

if this is considered a bug in the code here is my fix :

--- ext/standard/filestat.c     2 Jul 2006 13:51:40 -0000       1.136.2.8.2.3
+++ ext/standard/filestat.c     29 Oct 2006 23:45:54 -0000
@@ -660,7 +660,7 @@
        }

        if ((wrapper = php_stream_locate_url_wrapper(filename, &local, 0 TSRMLS_CC)) == &php_plain_files_wrapper) {
-               if (php_check_open_basedir(local TSRMLS_CC) || (PG(safe_mode) && !php_checkuid_ex(filename, NULL, CHECKUID_ALLOW_FILE_NOT_EXISTS, CHECKUID_NO_ERRORS))) {
+               if (php_check_open_basedir_ex(local, 0 TSRMLS_CC) || (PG(safe_mode) && !php_checkuid_ex(filename, NULL, CHECKUID_ALLOW_FILE_NOT_EXISTS, CHECKUID_NO_ERRORS))) {
                        RETURN_FALSE;
                }
        }

this change was introduced in php 5.1.5 by Ilia.
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/filestat.c?r1=1.136.2.8&r2=1.136.2.9

it this is considered not to be a bug, please update the documentation ;)
 [2006-11-03 13:40 UTC] iliaa@php.net
This should be documented.
 [2007-08-17 12:21 UTC] vrana@php.net
open_basedir says that all file operations are affected.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 08 03:01:32 2025 UTC