1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Add missing COMPILE_IGNORE_OTHER_FILES check for static calls
This commit is contained in:
Ilija Tovilo
2024-04-17 22:39:48 +02:00
2 changed files with 35 additions and 14 deletions

2
NEWS
View File

@@ -30,6 +30,8 @@ PHP NEWS
- Opcache:
. Fixed bug GH-13433 (Segmentation Fault in zend_class_init_statics when
using opcache.preload). (nielsdos)
. Fixed incorrect assumptions across compilation units for static calls.
(ilutov)
- OpenSSL:
. Fixed bug GH-10495 (feof on OpenSSL stream hangs indefinitely).

View File

@@ -4118,6 +4118,27 @@ static bool fbc_is_finalized(zend_function *fbc) {
return !ZEND_USER_CODE(fbc->type) || (fbc->common.fn_flags & ZEND_ACC_DONE_PASS_TWO);
}
static bool zend_compile_ignore_class(zend_class_entry *ce, zend_string *filename)
{
if (ce->type == ZEND_INTERNAL_CLASS) {
return CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES;
} else {
return (CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES)
&& ce->info.user.filename != filename;
}
}
static bool zend_compile_ignore_function(zend_function *fbc, zend_string *filename)
{
if (fbc->type == ZEND_INTERNAL_FUNCTION) {
return CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS;
} else {
return (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS)
|| ((CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES)
&& fbc->op_array.filename != filename);
}
}
static zend_result zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast, uint32_t num_args) /* {{{ */
{
zend_string *name, *lcname;
@@ -4132,11 +4153,9 @@ static zend_result zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast,
lcname = zend_string_tolower(name);
fbc = zend_hash_find_ptr(CG(function_table), lcname);
if (!fbc || !fbc_is_finalized(fbc)
|| (fbc->type == ZEND_INTERNAL_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS))
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS))
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES) && fbc->op_array.filename != CG(active_op_array)->filename)
) {
if (!fbc
|| !fbc_is_finalized(fbc)
|| zend_compile_ignore_function(fbc, CG(active_op_array)->filename)) {
zend_string_release_ex(lcname, 0);
return FAILURE;
}
@@ -4646,11 +4665,9 @@ static void zend_compile_call(znode *result, zend_ast *ast, uint32_t type) /* {{
return;
}
if (!fbc || !fbc_is_finalized(fbc)
|| (fbc->type == ZEND_INTERNAL_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS))
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_USER_FUNCTIONS))
|| (fbc->type == ZEND_USER_FUNCTION && (CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES) && fbc->op_array.filename != CG(active_op_array)->filename)
) {
if (!fbc
|| !fbc_is_finalized(fbc)
|| zend_compile_ignore_function(fbc, CG(active_op_array)->filename)) {
zend_string_release_ex(lcname, 0);
zend_compile_dynamic_call(result, &name_node, args_ast, ast->lineno);
return;
@@ -4817,7 +4834,11 @@ static void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type
if (opline->op1_type == IS_CONST) {
zend_string *lcname = Z_STR_P(CT_CONSTANT(opline->op1) + 1);
ce = zend_hash_find_ptr(CG(class_table), lcname);
if (!ce && CG(active_class_entry)
if (ce) {
if (zend_compile_ignore_class(ce, CG(active_op_array)->filename)) {
ce = NULL;
}
} else if (CG(active_class_entry)
&& zend_string_equals_ci(CG(active_class_entry)->name, lcname)) {
ce = CG(active_class_entry);
}
@@ -8162,9 +8183,7 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel)
ce->parent_name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
if (parent_ce
&& ((parent_ce->type != ZEND_INTERNAL_CLASS) || !(CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES))
&& ((parent_ce->type != ZEND_USER_CLASS) || !(CG(compiler_options) & ZEND_COMPILE_IGNORE_OTHER_FILES) || (parent_ce->info.user.filename == ce->info.user.filename))) {
&& !zend_compile_ignore_class(parent_ce, ce->info.user.filename)) {
if (zend_try_early_bind(ce, parent_ce, lcname, NULL)) {
zend_string_release(lcname);
return;