Skip to content

Commit 3026e88

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix phpGH-19792: SCCP causes UAF for return value if both warning and exception are triggered
2 parents 04587e3 + 2ad0b5c commit 3026e88

File tree

6 files changed

+55
-4
lines changed

6 files changed

+55
-4
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ PHP NEWS
66
. Fixed bug GH-19765 (object_properties_load() bypasses readonly property
77
checks). (timwolla)
88
. Fixed hard_timeout with --enable-zend-max-execution-timers. (Appla)
9+
. Fixed bug GH-19792 (SCCP causes UAF for return value if both warning and
10+
exception are triggered). (nielsdos)
911

1012
- Opcache:
1113
. Fixed bug GH-19669 (assertion failure in zend_jit_trace_type_to_info_ex).

Zend/Optimizer/sccp.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,9 +838,7 @@ static inline zend_result ct_eval_func_call_ex(
838838
zval_ptr_dtor(result);
839839
zend_clear_exception();
840840
retval = FAILURE;
841-
}
842-
843-
if (EG(capture_warnings_during_sccp) > 1) {
841+
} else if (EG(capture_warnings_during_sccp) > 1) {
844842
zval_ptr_dtor(result);
845843
retval = FAILURE;
846844
}

ext/opcache/tests/opt/gh19792.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
GH-19792 (SCCP causes UAF for return value if both warning and exception are triggered)
3+
--EXTENSIONS--
4+
opcache
5+
zend_test
6+
--INI--
7+
opcache.enable=1
8+
opcache.enable_cli=1
9+
opcache.optimization_level=-1
10+
--FILE--
11+
<?php
12+
13+
function foo()
14+
{
15+
return \zend_test_gh19792();
16+
}
17+
18+
try {
19+
foo();
20+
} catch (Error $e) {
21+
echo $e->getMessage(), "\n";
22+
}
23+
24+
?>
25+
--EXPECTF--
26+
Warning: a warning in %s on line %d
27+
an exception

ext/zend_test/test.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,3 +1588,12 @@ static PHP_FUNCTION(zend_test_gh18756)
15881588
zend_mm_gc(heap);
15891589
zend_mm_shutdown(heap, true, false);
15901590
}
1591+
1592+
static PHP_FUNCTION(zend_test_gh19792)
1593+
{
1594+
ZEND_PARSE_PARAMETERS_NONE();
1595+
1596+
RETVAL_STRING("this is a non-interned string");
1597+
zend_error(E_WARNING, "a warning");
1598+
zend_throw_error(NULL, "an exception");
1599+
}

ext/zend_test/test.stub.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ function zend_test_is_zend_ptr(int $addr): bool {}
318318
function zend_test_log_err_debug(string $str): void {}
319319

320320
function zend_test_gh18756(): void {}
321+
322+
/** @compile-time-eval */
323+
function zend_test_gh19792(): void {}
321324
}
322325

323326
namespace ZendTestNS {

ext/zend_test/test_arginfo.h

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)