From b9dcde1e25020f1742d8a0e7e5adbdeb758a913e Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 27 Apr 2010 10:38:16 +0000 Subject: [PATCH] "do not allow to fopen a directory" --- phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php b/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php index ea97d6e437..aa2d0ffcea 100644 --- a/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php +++ b/phpgwapi/inc/class.sqlfs_stream_wrapper.inc.php @@ -244,6 +244,17 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper self::mkdir_recursive($fs_dir,0700,true); } } + // check if opend file is a directory + elseif($stat && ($stat['mode'] & self::MODE_DIR) == self::MODE_DIR) + { + if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) Is a directory!"); + if (($options & STREAM_REPORT_ERRORS)) + { + trigger_error(__METHOD__."($url,$mode,$options) Is a directory!",E_USER_WARNING); + } + $this->opened_stream = $this->opened_path = $this->opened_mode = null; + return false; + } else { if ($mode == 'r' && !egw_vfs::check_access($url,egw_vfs::READABLE ,$stat) ||// we are not allowed to read @@ -993,7 +1004,7 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper */ static function url_stat ( $url, $flags, $eacl_access=null ) { - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags)"); + if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags,$eacl_access)"); $path = parse_url($url,PHP_URL_PATH);