Skip to content

Commit de9b3f6

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Propagate STREAM_DISABLE_OPEN_BASEDIR src flag to php_stream_stat_path_ex
2 parents a2d90aa + 8bf2d58 commit de9b3f6

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ PHP NEWS
88
- PGSQL:
99
. Fixed parameter parsing of pg_lo_export(). (kocsismate)
1010

11+
- Standard:
12+
. Fixed bug GH-11138 (move_uploaded_file() emits open_basedir warning for
13+
source file). (ilutov)
14+
1115
11 May 2023, PHP 8.2.6
1216

1317
- Core:

Zend/tests/gh11138.phpt

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
move_uploaded_file() emits open_basedir warning for source file
3+
--POST_RAW--
4+
Content-type: multipart/form-data, boundary=AaB03x
5+
6+
--AaB03x
7+
content-disposition: form-data; name="file"; filename="file.txt"
8+
Content-Type: text/plain
9+
10+
foo
11+
--AaB03x--
12+
--FILE--
13+
<?php
14+
15+
ini_set('open_basedir', __DIR__);
16+
17+
$destination = __DIR__ . '/gh11138.tmp';
18+
var_dump(move_uploaded_file($_FILES['file']['tmp_name'], $destination));
19+
echo file_get_contents($destination), "\n";
20+
21+
?>
22+
--CLEAN--
23+
<?php
24+
@unlink(__DIR__ . '/gh11138.tmp');
25+
?>
26+
--EXPECT--
27+
bool(true)
28+
foo

ext/standard/file.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1539,8 +1539,9 @@ PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_flg, php
15391539
php_stream *srcstream = NULL, *deststream = NULL;
15401540
int ret = FAILURE;
15411541
php_stream_statbuf src_s, dest_s;
1542+
int src_stat_flags = (src_flg & STREAM_DISABLE_OPEN_BASEDIR) ? PHP_STREAM_URL_STAT_IGNORE_OPEN_BASEDIR : 0;
15421543

1543-
switch (php_stream_stat_path_ex(src, 0, &src_s, ctx)) {
1544+
switch (php_stream_stat_path_ex(src, src_stat_flags, &src_s, ctx)) {
15441545
case -1:
15451546
/* non-statable stream */
15461547
goto safe_to_copy;

0 commit comments

Comments
 (0)