iliaa Tue Jun 24 09:56:25 2003 EDT Modified files: /php-src/main fopen_wrappers.h fopen_wrappers.c /php-src/ext/standard filestat.c /php-src/ext/standard/tests/file bug24313.phpt Log: Fix for bug #24313 (port from dead PHP_5 branch) Index: php-src/main/fopen_wrappers.h diff -u php-src/main/fopen_wrappers.h:1.41 php-src/main/fopen_wrappers.h:1.42 --- php-src/main/fopen_wrappers.h:1.41 Tue Jun 10 16:03:41 2003 +++ php-src/main/fopen_wrappers.h Tue Jun 24 09:56:25 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.h,v 1.41 2003/06/10 20:03:41 imajes Exp $ */ +/* $Id: fopen_wrappers.h,v 1.42 2003/06/24 13:56:25 iliaa Exp $ */ #ifndef FOPEN_WRAPPERS_H #define FOPEN_WRAPPERS_H @@ -28,6 +28,7 @@ PHPAPI char *expand_filepath(const char *filepath, char *real_path TSRMLS_DC); PHPAPI int php_check_open_basedir(const char *path TSRMLS_DC); +PHPAPI int php_check_open_basedir_ex(const char *path, int warn TSRMLS_DC); PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path TSRMLS_DC); PHPAPI int php_check_safe_mode_include_dir(char *path TSRMLS_DC); Index: php-src/main/fopen_wrappers.c diff -u php-src/main/fopen_wrappers.c:1.162 php-src/main/fopen_wrappers.c:1.163 --- php-src/main/fopen_wrappers.c:1.162 Tue Jun 10 16:03:41 2003 +++ php-src/main/fopen_wrappers.c Tue Jun 24 09:56:25 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.c,v 1.162 2003/06/10 20:03:41 imajes Exp $ */ +/* $Id: fopen_wrappers.c,v 1.163 2003/06/24 13:56:25 iliaa Exp $ */ /* {{{ includes */ @@ -162,9 +162,14 @@ } /* }}} */ +PHPAPI int php_check_open_basedir(const char *path TSRMLS_DC) +{ + return php_check_open_basedir_ex(path, 1 TSRMLS_DC); +} + /* {{{ php_check_open_basedir */ -PHPAPI int php_check_open_basedir(const char *path TSRMLS_DC) +PHPAPI int php_check_open_basedir_ex(const char *path, int warn TSRMLS_DC) { /* Only check when open_basedir is available */ if (PG(open_basedir) && *PG(open_basedir)) { @@ -190,8 +195,10 @@ ptr = end; } - php_error_docref(NULL TSRMLS_CC, E_WARNING, - "open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s)", path, PG(open_basedir)); + if (warn) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s)", path, PG(open_basedir)); + } efree(pathbuf); errno = EPERM; /* we deny permission to open it */ return -1; Index: php-src/ext/standard/filestat.c diff -u php-src/ext/standard/filestat.c:1.122 php-src/ext/standard/filestat.c:1.123 --- php-src/ext/standard/filestat.c:1.122 Tue Jun 10 16:03:37 2003 +++ php-src/ext/standard/filestat.c Tue Jun 24 09:56:25 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filestat.c,v 1.122 2003/06/10 20:03:37 imajes Exp $ */ +/* $Id: filestat.c,v 1.123 2003/06/24 13:56:25 iliaa Exp $ */ #include "php.h" #include "safe_mode.h" @@ -572,7 +572,7 @@ RETURN_FALSE; } - if (php_check_open_basedir(filename TSRMLS_CC)) { + if (php_check_open_basedir_ex(filename, IS_EXISTS_CHECK(type) ? 0 : 1 TSRMLS_CC)) { RETURN_FALSE; } Index: php-src/ext/standard/tests/file/bug24313.phpt diff -u /dev/null php-src/ext/standard/tests/file/bug24313.phpt:1.2 --- /dev/null Tue Jun 24 09:56:25 2003 +++ php-src/ext/standard/tests/file/bug24313.phpt Tue Jun 24 09:56:25 2003 @@ -0,0 +1,10 @@ +--TEST-- +Bug #24313: file_exists() warning on non-existant files when is open_basedir enabled +--INI-- +open_basedir=/tmp +--FILE-- +<?php + var_dump(file_exists("./foobar")); +?> +--EXPECT-- +bool(false)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php