From: Ilia Alshanetsky Date: Sun, 10 Nov 2002 05:14:26 +0000 (+0000) Subject: Fixed a bug that in many situations would cause open_basedir restriction to X-Git-Tag: php-4.3.0RC1~156 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91a203e8cd75d81107608db974b60667d5df8bf1;p=php Fixed a bug that in many situations would cause open_basedir restriction to be bypassed. Most notable exception, is the inclusion of files via include(), with a partial path. --- diff --git a/main/streams.c b/main/streams.c index 0a3ad4ca5a..1a27c7c4db 100755 --- a/main/streams.c +++ b/main/streams.c @@ -1626,26 +1626,28 @@ PHPAPI php_stream *_php_stream_fopen_with_path(char *filename, char *mode, char end++; } snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename); + + if (php_check_open_basedir(trypath TSRMLS_CC)) { + stream = NULL; + goto stream_done; + } + if (PG(safe_mode)) { if (VCWD_STAT(trypath, &sb) == 0) { /* file exists ... check permission */ - - if (php_check_open_basedir(trypath TSRMLS_CC)) { - stream = NULL; - } else if ((php_check_safe_mode_include_dir(trypath TSRMLS_CC) == 0) || + if ((php_check_safe_mode_include_dir(trypath TSRMLS_CC) == 0) || php_checkuid(trypath, mode, CHECKUID_CHECK_MODE_PARAM)) { /* UID ok, or trypath is in safe_mode_include_dir */ stream = php_stream_fopen_rel(trypath, mode, opened_path, options); } else { stream = NULL; } - - efree(pathbuf); - return stream; + goto stream_done; } } stream = php_stream_fopen_rel(trypath, mode, opened_path, options); if (stream) { + stream_done: efree(pathbuf); return stream; }