diff --git a/Zend/tests/gh11138.phpt b/Zend/tests/gh11138.phpt new file mode 100644 index 0000000000000..0744a0cdaa3e8 --- /dev/null +++ b/Zend/tests/gh11138.phpt @@ -0,0 +1,28 @@ +--TEST-- +move_uploaded_file() and open_basedir +--POST_RAW-- +Content-type: multipart/form-data, boundary=AaB03x + +--AaB03x +content-disposition: form-data; name="file"; filename="file.txt" +Content-Type: text/plain + +foo +--AaB03x-- +--FILE-- + +--CLEAN-- + +--EXPECT-- +bool(true) +foo diff --git a/ext/standard/file.c b/ext/standard/file.c index 548bcc7a37ca3..d51a584ed9c7a 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1669,8 +1669,9 @@ PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_flg, php php_stream *srcstream = NULL, *deststream = NULL; int ret = FAILURE; php_stream_statbuf src_s, dest_s; + int src_stat_flags = (src_flg & STREAM_DISABLE_OPEN_BASEDIR) ? PHP_STREAM_URL_STAT_IGNORE_OPEN_BASEDIR : 0; - switch (php_stream_stat_path_ex(src, 0, &src_s, ctx)) { + switch (php_stream_stat_path_ex(src, src_stat_flags, &src_s, ctx)) { case -1: /* non-statable stream */ goto safe_to_copy;