Skip to content

Commit b4abe9e

Browse files
committed
Merge remote-tracking branch 'php/master'
2 parents 5fe1dc1 + 0de8e40 commit b4abe9e

File tree

9 files changed

+119
-8
lines changed

9 files changed

+119
-8
lines changed

Zend/tests/gh16799.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
GH-16799 (Assertion failure at Zend/zend_vm_execute.h)
3+
--FILE--
4+
<?php
5+
set_error_handler(function($_, $m) { throw new Exception($m); });
6+
class Test {
7+
static function test() {
8+
call_user_func("static::ok");
9+
}
10+
static function ok() {
11+
}
12+
}
13+
Test::test();
14+
?>
15+
--EXPECTF--
16+
Fatal error: Uncaught Exception: Use of "static" in callables is deprecated in %s:%d
17+
Stack trace:
18+
#0 %s(%d): {closure:%s:%d}(8192, 'Use of "static"...', %s, %d)
19+
#1 %s(%d): Test::test()
20+
#2 {main}
21+
thrown in %s on line %d

Zend/zend_vm_def.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3918,6 +3918,16 @@ ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMPVAR|CV, NUM)
39183918
function_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
39193919
if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) {
39203920
ZEND_ASSERT(!error);
3921+
3922+
/* Deprecation can be emitted from zend_is_callable_ex(), which can
3923+
* invoke a user error handler and throw an exception.
3924+
* For the CONST and CV case we reuse the same exception block below
3925+
* to make sure we don't increase VM size too much. */
3926+
if (!(OP2_TYPE & (IS_TMP_VAR|IS_VAR)) && UNEXPECTED(EG(exception))) {
3927+
FREE_OP2();
3928+
HANDLE_EXCEPTION();
3929+
}
3930+
39213931
func = fcc.function_handler;
39223932
object_or_called_scope = fcc.called_scope;
39233933
if (func->common.fn_flags & ZEND_ACC_CLOSURE) {

Zend/zend_vm_execute.h

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/curl/interface.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,10 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
19361936
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
19371937
#if LIBCURL_VERSION_NUM >= 0x075500 /* Available since 7.85.0 */
19381938
if ((option == CURLOPT_PROTOCOLS_STR || option == CURLOPT_REDIR_PROTOCOLS_STR) &&
1939-
(PG(open_basedir) && *PG(open_basedir)) && php_memnistr(ZSTR_VAL(str), "file", sizeof("file") - 1, ZSTR_VAL(str) + ZSTR_LEN(str)) != NULL) {
1939+
(PG(open_basedir) && *PG(open_basedir))
1940+
&& (php_memnistr(ZSTR_VAL(str), "file", sizeof("file") - 1, ZSTR_VAL(str) + ZSTR_LEN(str)) != NULL
1941+
|| php_memnistr(ZSTR_VAL(str), "all", sizeof("all") - 1, ZSTR_VAL(str) + ZSTR_LEN(str)) != NULL)) {
1942+
zend_tmp_string_release(tmp_str);
19401943
php_error_docref(NULL, E_WARNING, "The FILE protocol cannot be activated when an open_basedir is set");
19411944
return FAILURE;
19421945
}

ext/curl/tests/gh16802.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
GH-16802 (open_basedir bypass using curl extension)
3+
--EXTENSIONS--
4+
curl
5+
--SKIPIF--
6+
<?php
7+
$curl_version = curl_version();
8+
if ($curl_version['version_number'] < 0x075500) {
9+
die("skip: blob options not supported for curl < 7.85.0");
10+
}
11+
?>
12+
--INI--
13+
open_basedir=/nowhere
14+
--FILE--
15+
<?php
16+
$ch = curl_init("file:///etc/passwd");
17+
curl_setopt($ch, CURLOPT_PROTOCOLS_STR, "all");
18+
curl_setopt($ch, CURLOPT_PROTOCOLS_STR, "ftp,all");
19+
curl_setopt($ch, CURLOPT_PROTOCOLS_STR, "all,ftp");
20+
curl_setopt($ch, CURLOPT_PROTOCOLS_STR, "all,file,ftp");
21+
var_dump(curl_exec($ch));
22+
?>
23+
--EXPECTF--
24+
Warning: curl_setopt(): The FILE protocol cannot be activated when an open_basedir is set in %s on line %d
25+
26+
Warning: curl_setopt(): The FILE protocol cannot be activated when an open_basedir is set in %s on line %d
27+
28+
Warning: curl_setopt(): The FILE protocol cannot be activated when an open_basedir is set in %s on line %d
29+
30+
Warning: curl_setopt(): The FILE protocol cannot be activated when an open_basedir is set in %s on line %d
31+
bool(false)

ext/intl/tests/timezone_IDforWindowsID_basic_icu76_1.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ foreach ($tzs as $tz => $regions) {
2424
}
2525
}
2626
?>
27-
--EXPECT--
27+
--EXPECTF--
2828
** Gnomeregan
2929
bool(false)
30-
Error: unknown windows timezone: U_ILLEGAL_ARGUMENT_ERROR
30+
Error: %snknown windows timezone: U_ILLEGAL_ARGUMENT_ERROR
3131
** India Standard Time
3232
string(13) "Asia/Calcutta"
3333
** Pacific Standard Time

ext/libxml/config.w32

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ ARG_WITH("libxml", "LibXML support", "yes");
44

55
if (PHP_LIBXML == "yes") {
66
if (CHECK_LIB("libxml2_a_dll.lib;libxml2_a.lib", "libxml") &&
7-
CHECK_LIB("libiconv_a.lib;iconv_a.lib;libiconv.lib;iconv.lib", "libxml") &&
7+
((PHP_ICONV != "no" && !PHP_ICONV_SHARED) || CHECK_LIB("libiconv_a.lib;iconv_a.lib;libiconv.lib;iconv.lib", "libxml")) &&
88
CHECK_HEADER_ADD_INCLUDE("libxml/parser.h", "CFLAGS_LIBXML", PHP_PHP_BUILD + "\\include\\libxml2") &&
9-
CHECK_HEADER_ADD_INCLUDE("libxml/tree.h", "CFLAGS_LIBXML", PHP_PHP_BUILD + "\\include\\libxml2") &&
10-
ADD_EXTENSION_DEP('libxml', 'iconv')) {
9+
CHECK_HEADER_ADD_INCLUDE("libxml/tree.h", "CFLAGS_LIBXML", PHP_PHP_BUILD + "\\include\\libxml2")) {
1110

1211
if (GREP_HEADER("libxml/xmlversion.h", "#define\\s+LIBXML_VERSION\\s+(\\d+)", PHP_PHP_BUILD + "\\include\\libxml2") &&
1312
+RegExp.$1 >= 20904) {

ext/readline/readline.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ PHP_FUNCTION(readline_info)
181181
add_assoc_long(return_value,"attempted_completion_over",rl_attempted_completion_over);
182182
} else {
183183
if (zend_string_equals_literal_ci(what,"line_buffer")) {
184-
oldstr = rl_line_buffer;
184+
oldstr = strdup(rl_line_buffer ? rl_line_buffer : "");
185185
if (value) {
186186
if (!try_convert_to_string(value)) {
187187
RETURN_THROWS();
@@ -191,7 +191,8 @@ PHP_FUNCTION(readline_info)
191191
rl_line_buffer = malloc(Z_STRLEN_P(value) + 1);
192192
} else if (strlen(oldstr) < Z_STRLEN_P(value)) {
193193
rl_extend_line_buffer(Z_STRLEN_P(value) + 1);
194-
oldstr = rl_line_buffer;
194+
free(oldstr);
195+
oldstr = strdup(rl_line_buffer ? rl_line_buffer : "");
195196
}
196197
memcpy(rl_line_buffer, Z_STRVAL_P(value), Z_STRLEN_P(value) + 1);
197198
#else
@@ -208,6 +209,7 @@ PHP_FUNCTION(readline_info)
208209
#endif
209210
}
210211
RETVAL_STRING(SAFE_STRING(oldstr));
212+
free(oldstr);
211213
} else if (zend_string_equals_literal_ci(what, "point")) {
212214
RETVAL_LONG(rl_point);
213215
#ifndef PHP_WIN32

ext/readline/tests/gh16812.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
GH-16812 readline_info(): UAF
3+
--EXTENSIONS--
4+
readline
5+
--SKIPIF--
6+
<?php
7+
if (getenv('SKIP_REPEAT')) die("skip readline has global state");
8+
?>
9+
--FILE--
10+
<?php
11+
readline_write_history(NULL);
12+
var_dump(readline_info('line_buffer', 'test'));
13+
?>
14+
--EXPECT--
15+
string(0) ""

0 commit comments

Comments
 (0)