summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2003-12-01 19:47:05 +0000
committerSara Golemon <pollita@php.net>2003-12-01 19:47:05 +0000
commit681d18effd5c8e65646593e426f2e93b10a3333f (patch)
treed072ac533c7d3cec6be83065e0b2967e7371e1f8 /main
parent74eed61504786f787d8c1d04e15800bae2b2b84e (diff)
downloadphp-git-681d18effd5c8e65646593e426f2e93b10a3333f.tar.gz
Move safemode/basedir checks for url_stat to plain_wrapper.
Diffstat (limited to 'main')
-rwxr-xr-xmain/php_streams.h1
-rw-r--r--main/streams/plain_wrapper.c13
2 files changed, 14 insertions, 0 deletions
diff --git a/main/php_streams.h b/main/php_streams.h
index fac56a06d1..5451b8382f 100755
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -319,6 +319,7 @@ PHPAPI int _php_stream_set_option(php_stream *stream, int option, int value, voi
/* Flags for url_stat method in wrapper ops */
#define PHP_STREAM_URL_STAT_LINK 1
+#define PHP_STREAM_URL_STAT_QUIET 2
/* change the blocking mode of stream: value == 1 => blocking, value == 0 => non-blocking. */
#define PHP_STREAM_OPTION_BLOCKING 1
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index b78c2d9651..ffaeb31bd9 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -898,6 +898,19 @@ static php_stream *php_plain_files_stream_opener(php_stream_wrapper *wrapper, ch
static int php_plain_files_url_stater(php_stream_wrapper *wrapper, char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC)
{
+
+ if (strncmp(url, "file://", 7) == 0) {
+ url += 7;
+ }
+
+ if (PG(safe_mode) &&(!php_checkuid_ex(url, NULL, CHECKUID_CHECK_FILE_AND_DIR, (flags & PHP_STREAM_URL_STAT_QUIET) ? CHECKUID_NO_ERRORS : 0))) {
+ return -1;
+ }
+
+ if (php_check_open_basedir_ex(url, (flags & PHP_STREAM_URL_STAT_QUIET) ? 0 : 1 TSRMLS_CC)) {
+ return -1;
+ }
+
#ifdef HAVE_SYMLINK
if (flags & PHP_STREAM_URL_STAT_LINK) {
return VCWD_LSTAT(url, &ssb->sb);