diff --git a/NEWS b/NEWS index d5e883d9d7745..ec0475c4779ef 100644 --- a/NEWS +++ b/NEWS @@ -98,6 +98,8 @@ PHP NEWS ACK delays. (David Carlier) . Added DONTFRAGMENT support for path MTU discovery purpose. (David Carlier) . Added AF_DIVERT for raw socket for divert ports. (David Carlier) + . Added SOL_UPDLITE, UDPLITE_RECV_CSCOV and UDPLITE_SEND_CSCOV for updlite + protocol support. (David Carlier) - Standard: . E_NOTICEs emitted by unserialize() have been promoted to E_WARNING. (timwolla) diff --git a/UPGRADING b/UPGRADING index 589692aa1e446..9b5febd600377 100644 --- a/UPGRADING +++ b/UPGRADING @@ -141,6 +141,9 @@ PHP 8.3 UPGRADE NOTES . IP_PMTUDISC_INTERFACE (Linux only). . IP_PMTUDISC_OMIT (Linux only). . AF_DIVERT (FreeBSD only). + . SOL_UDPLITE. + . UDPLITE_RECV_CSCOV. + . UDPLITE_SEND_CSCOV. ======================================== 11. Changes to INI File Handling diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index f0f027542a241..bc55ceaefc372 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -2569,12 +2569,26 @@ static zend_always_inline zend_result _zend_update_type_info( } else if (opline->opcode == ZEND_ASSIGN_OBJ_OP) { /* The return value must also satisfy the property type */ if (prop_info) { - tmp &= zend_fetch_prop_type(script, prop_info, NULL); + t1 = zend_fetch_prop_type(script, prop_info, NULL); + if ((t1 & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_LONG + && (tmp & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_DOUBLE) { + /* DOUBLE may be auto-converted to LONG */ + tmp |= MAY_BE_LONG; + tmp &= ~MAY_BE_DOUBLE; + } + tmp &= t1; } } else if (opline->opcode == ZEND_ASSIGN_STATIC_PROP_OP) { /* The return value must also satisfy the property type */ if (prop_info) { - tmp &= zend_fetch_prop_type(script, prop_info, NULL); + t1 = zend_fetch_prop_type(script, prop_info, NULL); + if ((t1 & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_LONG + && (tmp & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_DOUBLE) { + /* DOUBLE may be auto-converted to LONG */ + tmp |= MAY_BE_LONG; + tmp &= ~MAY_BE_DOUBLE; + } + tmp &= t1; } } else { if (tmp & MAY_BE_REF) { diff --git a/Zend/tests/036.phpt b/Zend/tests/036.phpt index 8f74bccc075f0..4037d3d0e3d21 100644 --- a/Zend/tests/036.phpt +++ b/Zend/tests/036.phpt @@ -11,4 +11,4 @@ try { ?> --EXPECT-- -Illegal offset type +Cannot access offset of type object on array diff --git a/Zend/tests/038.phpt b/Zend/tests/038.phpt index e55757bbcd417..4f822a6f5a154 100644 --- a/Zend/tests/038.phpt +++ b/Zend/tests/038.phpt @@ -11,4 +11,4 @@ try { ?> --EXPECT-- -Illegal offset type +Cannot access offset of type object on array diff --git a/Zend/tests/assign_dim_obj_null_return.phpt b/Zend/tests/assign_dim_obj_null_return.phpt index 0a2ea94c552d5..02e709818669e 100644 --- a/Zend/tests/assign_dim_obj_null_return.phpt +++ b/Zend/tests/assign_dim_obj_null_return.phpt @@ -72,12 +72,12 @@ test(); ?> --EXPECT-- Cannot add element to the array as the next element is already occupied -Illegal offset type -Illegal offset type +Cannot access offset of type array on array +Cannot access offset of type object on array Cannot use a scalar value as an array Cannot add element to the array as the next element is already occupied -Illegal offset type -Illegal offset type +Cannot access offset of type array on array +Cannot access offset of type object on array Cannot use a scalar value as an array Attempt to assign property "foo" on true Attempt to assign property "foo" on true diff --git a/Zend/tests/bug79790.phpt b/Zend/tests/bug79790.phpt index 4fce25291bcb5..0d34e2be0fc1e 100644 --- a/Zend/tests/bug79790.phpt +++ b/Zend/tests/bug79790.phpt @@ -8,7 +8,7 @@ function b($a = array()[array ()]) { } ?> --EXPECTF-- -Fatal error: Uncaught TypeError: Illegal offset type in %s:%d +Fatal error: Uncaught TypeError: Cannot access offset of type array on array in %s:%d Stack trace: #0 %s(%d): b() #1 {main} diff --git a/Zend/tests/bug79947.phpt b/Zend/tests/bug79947.phpt index 906f58144b41d..0593eacfd6c48 100644 --- a/Zend/tests/bug79947.phpt +++ b/Zend/tests/bug79947.phpt @@ -12,6 +12,6 @@ try { var_dump($array); ?> --EXPECT-- -Illegal offset type +Cannot access offset of type array on array array(0) { } diff --git a/Zend/tests/bug80781.phpt b/Zend/tests/bug80781.phpt index eb5109add9f6c..0dc004fb9d74c 100644 --- a/Zend/tests/bug80781.phpt +++ b/Zend/tests/bug80781.phpt @@ -25,7 +25,7 @@ if (isset($array[$data]) or getPlugin($data)) { ?> --EXPECTF-- -Fatal error: Uncaught TypeError: Illegal offset type in isset or empty in %s:%d +Fatal error: Uncaught TypeError: Cannot access offset of type array in isset or empty in %s:%d Stack trace: #0 {main} thrown in %s on line %d diff --git a/Zend/tests/constant_expressions_invalid_offset_type_error.phpt b/Zend/tests/constant_expressions_invalid_offset_type_error.phpt index 649c3a325a0c2..1a0ef52dce082 100644 --- a/Zend/tests/constant_expressions_invalid_offset_type_error.phpt +++ b/Zend/tests/constant_expressions_invalid_offset_type_error.phpt @@ -8,7 +8,7 @@ const C2 = [C1, [] => 1]; ?> --EXPECTF-- -Fatal error: Uncaught TypeError: Illegal offset type in %s:%d +Fatal error: Uncaught TypeError: Cannot access offset of type array on array in %s:%d Stack trace: #0 {main} thrown in %s on line %d diff --git a/Zend/tests/fibers/get-return-after-bailout.phpt b/Zend/tests/fibers/get-return-after-bailout.phpt index 0f004070251b5..04bd464cfab0e 100644 --- a/Zend/tests/fibers/get-return-after-bailout.phpt +++ b/Zend/tests/fibers/get-return-after-bailout.phpt @@ -1,5 +1,12 @@ --TEST-- Fiber::getReturn() after bailout +--SKIPIF-- + --FILE-- start(); + +?> +--EXPECTF-- +Fatal error: Bailout in fiber in %sgh10437.php on line %d +NULL diff --git a/Zend/tests/generators/gh9801.phpt b/Zend/tests/generators/gh9801.phpt index cc229ab0db89c..0d5990f9ba442 100644 --- a/Zend/tests/generators/gh9801.phpt +++ b/Zend/tests/generators/gh9801.phpt @@ -2,6 +2,13 @@ Bug GH-9801 (Crash when memory limit is exceeded during generator initialization) --INI-- memory_limit=16m +--SKIPIF-- + --FILE-- current(); +}); +$fiber->start(); + +?> +==DONE== +--EXPECT-- +==DONE== diff --git a/Zend/tests/illegal_offset_unset_isset_empty.phpt b/Zend/tests/illegal_offset_unset_isset_empty.phpt index 9005053e67ed8..9e5818136445d 100644 --- a/Zend/tests/illegal_offset_unset_isset_empty.phpt +++ b/Zend/tests/illegal_offset_unset_isset_empty.phpt @@ -22,6 +22,6 @@ try { ?> --EXPECT-- -Illegal offset type in unset -Illegal offset type in isset or empty -Illegal offset type in isset or empty +Cannot access offset of type array on unset +Cannot access offset of type array in isset or empty +Cannot access offset of type array in isset or empty diff --git a/Zend/tests/init_array_illegal_offset_type.phpt b/Zend/tests/init_array_illegal_offset_type.phpt index 2243ca2905ea0..2e5a0401d6e4a 100644 --- a/Zend/tests/init_array_illegal_offset_type.phpt +++ b/Zend/tests/init_array_illegal_offset_type.phpt @@ -12,4 +12,4 @@ try { } ?> --EXPECT-- -Illegal offset type +Cannot access offset of type object on array diff --git a/Zend/tests/isset_array.phpt b/Zend/tests/isset_array.phpt index 4a0652ae39d5f..792483294805d 100644 --- a/Zend/tests/isset_array.phpt +++ b/Zend/tests/isset_array.phpt @@ -46,5 +46,5 @@ bool(false) Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d bool(false) -Illegal offset type in isset or empty -Illegal offset type in isset or empty +Cannot access offset of type array in isset or empty +Cannot access offset of type object in isset or empty diff --git a/Zend/tests/offset_array.phpt b/Zend/tests/offset_array.phpt index 0109950cde848..c526beca91a89 100644 --- a/Zend/tests/offset_array.phpt +++ b/Zend/tests/offset_array.phpt @@ -30,6 +30,14 @@ try { echo $e->getMessage(), "\n"; } +try{ + $k = []; + $arr = ['foo']; + $arr[$k]; +}catch (Error $e){ + echo $e->getMessage(), "\n"; +} + echo "Done\n"; ?> --EXPECTF-- @@ -48,6 +56,7 @@ int(1) Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d int(%d) -Illegal offset type -Illegal offset type +Cannot access offset of type object on array +Cannot access offset of type array on array +Cannot access offset of type array on array Done diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 21e768f0947c3..e2045b755882b 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2046,6 +2046,21 @@ ZEND_API zend_result add_next_index_reference(zval *arg, zend_reference *ref) /* } /* }}} */ +void zend_illegal_empty_or_isset_offset(const zval *offset) +{ + zend_type_error("Cannot access offset of type %s in isset or empty", zend_get_type_by_const(Z_TYPE_P(offset))); +} + +void zend_illegal_unset_offset(const zval *offset) +{ + zend_type_error("Cannot access offset of type %s on unset", zend_get_type_by_const(Z_TYPE_P(offset))); +} + +void zend_illegal_array_offset(const zval *offset) +{ + zend_type_error("Cannot access offset of type %s on array", zend_get_type_by_const(Z_TYPE_P(offset))); +} + ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */ { zval *result; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index c2d53bd943ec7..4582e53083f16 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8752,6 +8752,7 @@ static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */ default: zend_error_noreturn(E_COMPILE_ERROR, "Illegal offset type"); break; + } } else if (!zend_hash_next_index_insert(Z_ARRVAL_P(result), value)) { zval_ptr_dtor_nogc(value); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index b051937a5bc08..c58da4b00e450 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1455,11 +1455,6 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(v zend_throw_error(NULL, "Cannot use object as array"); } -static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_offset(void) -{ - zend_type_error("Illegal offset type"); -} - static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_string_offset(const zval *offset) { zend_type_error("Cannot access offset of type %s on string", zend_zval_type_name(offset)); @@ -2329,7 +2324,7 @@ static zend_never_inline zend_uchar slow_index_convert(HashTable *ht, const zval value->lval = 1; return IS_LONG; default: - zend_illegal_offset(); + zend_illegal_array_offset(dim); return IS_NULL; } } @@ -2403,7 +2398,7 @@ static zend_never_inline zend_uchar slow_index_convert_w(HashTable *ht, const zv value->lval = 1; return IS_LONG; default: - zend_illegal_offset(); + zend_illegal_array_offset(dim); return IS_NULL; } } @@ -2985,7 +2980,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable str = ZSTR_EMPTY_ALLOC(); goto str_key; } else { - zend_illegal_offset(); + zend_illegal_array_offset(key); return 0; } } diff --git a/Zend/zend_fibers.c b/Zend/zend_fibers.c index 50c7ef9635f3d..5edefdb8052fb 100644 --- a/Zend/zend_fibers.c +++ b/Zend/zend_fibers.c @@ -645,6 +645,7 @@ static zend_always_inline zend_fiber_transfer zend_fiber_switch_to( /* Forward bailout into current fiber. */ if (UNEXPECTED(transfer.flags & ZEND_FIBER_TRANSFER_FLAG_BAILOUT)) { + EG(active_fiber) = NULL; zend_bailout(); } diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index fb1e2e6d52a73..958d9784c9458 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -223,6 +223,14 @@ static void zend_generator_dtor_storage(zend_object *object) /* {{{ */ uint32_t op_num, try_catch_offset; int i; + /* Generator is running in a suspended fiber. + * Will be dtor during fiber dtor */ + if (zend_generator_get_current(generator)->flags & ZEND_GENERATOR_IN_FIBER) { + /* Prevent finally blocks from yielding */ + generator->flags |= ZEND_GENERATOR_FORCED_CLOSE; + return; + } + /* leave yield from mode to properly allow finally execution */ if (UNEXPECTED(Z_TYPE(generator->values) != IS_UNDEF)) { zval_ptr_dtor(&generator->values); diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index fc7cd81323987..4b7902be7675a 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -6055,7 +6055,7 @@ ZEND_VM_C_LABEL(num_index): str = ZSTR_EMPTY_ALLOC(); ZEND_VM_C_GOTO(str_index); } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } FREE_OP2(); @@ -6571,7 +6571,7 @@ ZEND_VM_C_LABEL(num_index_dim): key = ZSTR_EMPTY_ALLOC(); ZEND_VM_C_GOTO(str_index_dim); } else { - zend_type_error("Illegal offset type in unset"); + zend_illegal_unset_offset(offset); } break; } else if (Z_ISREF_P(container)) { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index a1eefaa72e336..585b9ec6df141 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -7342,7 +7342,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_C str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } @@ -9655,7 +9655,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_T str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); @@ -10578,7 +10578,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_U str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } @@ -12020,7 +12020,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_C str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } @@ -19992,7 +19992,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CON str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } @@ -20432,7 +20432,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_TMP str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); @@ -20893,7 +20893,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_UNU str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } @@ -21293,7 +21293,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_TMP_CV_ str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } @@ -25060,7 +25060,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CON str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } @@ -25152,7 +25152,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CONST_HANDL key = ZSTR_EMPTY_ALLOC(); goto str_index_dim; } else { - zend_type_error("Illegal offset type in unset"); + zend_illegal_unset_offset(offset); } break; } else if (Z_ISREF_P(container)) { @@ -27468,7 +27468,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_TMP str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); @@ -27560,7 +27560,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_TMPVAR_HAND key = ZSTR_EMPTY_ALLOC(); goto str_index_dim; } else { - zend_type_error("Illegal offset type in unset"); + zend_illegal_unset_offset(offset); } break; } else if (Z_ISREF_P(container)) { @@ -29489,7 +29489,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_UNU str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } @@ -31744,7 +31744,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_VAR_CV_ str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } @@ -31836,7 +31836,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_VAR_CV_HANDLER( key = ZSTR_EMPTY_ALLOC(); goto str_index_dim; } else { - zend_type_error("Illegal offset type in unset"); + zend_illegal_unset_offset(offset); } break; } else if (Z_ISREF_P(container)) { @@ -43236,7 +43236,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CONS str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } @@ -43328,7 +43328,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CONST_HANDLE key = ZSTR_EMPTY_ALLOC(); goto str_index_dim; } else { - zend_type_error("Illegal offset type in unset"); + zend_illegal_unset_offset(offset); } break; } else if (Z_ISREF_P(container)) { @@ -46836,7 +46836,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_TMPV str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); @@ -46928,7 +46928,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_TMPVAR_HANDL key = ZSTR_EMPTY_ALLOC(); goto str_index_dim; } else { - zend_type_error("Illegal offset type in unset"); + zend_illegal_unset_offset(offset); } break; } else if (Z_ISREF_P(container)) { @@ -48741,7 +48741,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_UNUS str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } @@ -52229,7 +52229,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ADD_ARRAY_ELEMENT_SPEC_CV_CV_H str = ZSTR_EMPTY_ALLOC(); goto str_index; } else { - zend_illegal_offset(); + zend_illegal_array_offset(offset); zval_ptr_dtor_nogc(expr_ptr); } @@ -52321,7 +52321,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_UNSET_DIM_SPEC_CV_CV_HANDLER(Z key = ZSTR_EMPTY_ALLOC(); goto str_index_dim; } else { - zend_type_error("Illegal offset type in unset"); + zend_illegal_unset_offset(offset); } break; } else if (Z_ISREF_P(container)) { diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 8d218c1d6d0a1..22353d6a7541c 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -722,7 +722,7 @@ static zend_string *date_format(const char *format, size_t format_len, timelib_t /* timezone */ case 'I': length = slprintf(buffer, sizeof(buffer), "%d", localtime ? offset->is_dst : 0); break; case 'p': - if (!localtime || strcmp(offset->abbr, "UTC") == 0 || strcmp(offset->abbr, "Z") == 0) { + if (!localtime || strcmp(offset->abbr, "UTC") == 0 || strcmp(offset->abbr, "Z") == 0 || strcmp(offset->abbr, "GMT+0000") == 0) { length = slprintf(buffer, sizeof(buffer), "%s", "Z"); break; } @@ -2254,6 +2254,19 @@ static void date_object_free_storage_period(zend_object *object) /* {{{ */ zend_object_std_dtor(&intern->std); } /* }}} */ +static void add_common_properties(HashTable *myht, zend_object *zobj) +{ + HashTable *common; + zend_string *name; + zval *prop; + + common = zend_std_get_properties(zobj); + + ZEND_HASH_MAP_FOREACH_STR_KEY_VAL_IND(common, name, prop) { + zend_hash_add(myht, name, prop); + } ZEND_HASH_FOREACH_END(); +} + /* Advanced Interface */ PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object) /* {{{ */ { @@ -2733,6 +2746,8 @@ PHP_METHOD(DateTime, __serialize) array_init(return_value); myht = Z_ARRVAL_P(return_value); date_object_to_hash(dateobj, myht); + + add_common_properties(myht, &dateobj->std); } /* }}} */ @@ -2751,9 +2766,36 @@ PHP_METHOD(DateTimeImmutable, __serialize) array_init(return_value); myht = Z_ARRVAL_P(return_value); date_object_to_hash(dateobj, myht); + + add_common_properties(myht, &dateobj->std); } /* }}} */ +static bool date_time_is_internal_property(zend_string *name) +{ + if ( + zend_string_equals_literal(name, "date") || + zend_string_equals_literal(name, "timezone_type") || + zend_string_equals_literal(name, "timezone") + ) { + return 1; + } + return 0; +} + +static void restore_custom_datetime_properties(zval *object, HashTable *myht) +{ + zend_string *prop_name; + zval *prop_val; + + ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(myht, prop_name, prop_val) { + if (date_time_is_internal_property(prop_name)) { + continue; + } + add_property_zval_ex(object, ZSTR_VAL(prop_name), ZSTR_LEN(prop_name), prop_val); + } ZEND_HASH_FOREACH_END(); +} + /* {{{ */ PHP_METHOD(DateTime, __unserialize) { @@ -2772,6 +2814,8 @@ PHP_METHOD(DateTime, __unserialize) if (!php_date_initialize_from_hash(&dateobj, myht)) { zend_throw_error(NULL, "Invalid serialization data for DateTime object"); } + + restore_custom_datetime_properties(object, myht); } /* }}} */ @@ -2793,6 +2837,8 @@ PHP_METHOD(DateTimeImmutable, __unserialize) if (!php_date_initialize_from_hash(&dateobj, myht)) { zend_throw_error(NULL, "Invalid serialization data for DateTimeImmutable object"); } + + restore_custom_datetime_properties(object, myht); } /* }}} */ @@ -3753,9 +3799,35 @@ PHP_METHOD(DateTimeZone, __serialize) array_init(return_value); myht = Z_ARRVAL_P(return_value); date_timezone_object_to_hash(tzobj, myht); + + add_common_properties(myht, &tzobj->std); } /* }}} */ +static bool date_timezone_is_internal_property(zend_string *name) +{ + if ( + zend_string_equals_literal(name, "timezone_type") || + zend_string_equals_literal(name, "timezone") + ) { + return 1; + } + return 0; +} + +static void restore_custom_datetimezone_properties(zval *object, HashTable *myht) +{ + zend_string *prop_name; + zval *prop_val; + + ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(myht, prop_name, prop_val) { + if (date_timezone_is_internal_property(prop_name)) { + continue; + } + add_property_zval_ex(object, ZSTR_VAL(prop_name), ZSTR_LEN(prop_name), prop_val); + } ZEND_HASH_FOREACH_END(); +} + /* {{{ */ PHP_METHOD(DateTimeZone, __unserialize) { @@ -3774,6 +3846,8 @@ PHP_METHOD(DateTimeZone, __unserialize) if (!php_date_timezone_initialize_from_hash(&object, &tzobj, myht)) { zend_throw_error(NULL, "Invalid serialization data for DateTimeZone object"); } + + restore_custom_datetimezone_properties(object, myht); } /* }}} */ @@ -4344,9 +4418,44 @@ PHP_METHOD(DateInterval, __serialize) array_init(return_value); myht = Z_ARRVAL_P(return_value); date_interval_object_to_hash(intervalobj, myht); + + add_common_properties(myht, &intervalobj->std); } /* }}} */ +static bool date_interval_is_internal_property(zend_string *name) +{ + if ( + zend_string_equals_literal(name, "date_string") || + zend_string_equals_literal(name, "from_string") || + zend_string_equals_literal(name, "y") || + zend_string_equals_literal(name, "m") || + zend_string_equals_literal(name, "d") || + zend_string_equals_literal(name, "h") || + zend_string_equals_literal(name, "i") || + zend_string_equals_literal(name, "s") || + zend_string_equals_literal(name, "f") || + zend_string_equals_literal(name, "invert") || + zend_string_equals_literal(name, "days") + ) { + return 1; + } + return 0; +} + +static void restore_custom_dateinterval_properties(zval *object, HashTable *myht) +{ + zend_string *prop_name; + zval *prop_val; + + ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(myht, prop_name, prop_val) { + if (date_interval_is_internal_property(prop_name)) { + continue; + } + add_property_zval_ex(object, ZSTR_VAL(prop_name), ZSTR_LEN(prop_name), prop_val); + } ZEND_HASH_FOREACH_END(); +} + /* {{{ */ PHP_METHOD(DateInterval, __unserialize) @@ -4364,6 +4473,7 @@ PHP_METHOD(DateInterval, __unserialize) myht = Z_ARRVAL_P(array); php_date_interval_initialize_from_hash(&object, &intervalobj, myht); + restore_custom_dateinterval_properties(object, myht); } /* }}} */ @@ -5269,9 +5379,44 @@ PHP_METHOD(DatePeriod, __serialize) array_init(return_value); myht = Z_ARRVAL_P(return_value); date_period_object_to_hash(period_obj, myht); + + add_common_properties(myht, &period_obj->std); } /* }}} */ +/* {{{ date_period_is_internal_property + * Common for date_period_read_property(), date_period_write_property(), and + * restore_custom_dateperiod_properties functions + */ +static bool date_period_is_internal_property(zend_string *name) +{ + if ( + zend_string_equals_literal(name, "start") || + zend_string_equals_literal(name, "current") || + zend_string_equals_literal(name, "end") || + zend_string_equals_literal(name, "interval") || + zend_string_equals_literal(name, "recurrences") || + zend_string_equals_literal(name, "include_start_date") || + zend_string_equals_literal(name, "include_end_date") + ) { + return 1; + } + return 0; +} +/* }}} */ + +static void restore_custom_dateperiod_properties(zval *object, HashTable *myht) +{ + zend_string *prop_name; + zval *prop_val; + + ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(myht, prop_name, prop_val) { + if (date_period_is_internal_property(prop_name)) { + continue; + } + add_property_zval_ex(object, ZSTR_VAL(prop_name), ZSTR_LEN(prop_name), prop_val); + } ZEND_HASH_FOREACH_END(); +} /* {{{ */ PHP_METHOD(DatePeriod, __unserialize) @@ -5291,6 +5436,7 @@ PHP_METHOD(DatePeriod, __unserialize) if (!php_date_period_initialize_from_hash(period_obj, myht)) { zend_throw_error(NULL, "Invalid serialization data for DatePeriod object"); } + restore_custom_dateperiod_properties(object, myht); } /* }}} */ @@ -5313,25 +5459,6 @@ PHP_METHOD(DatePeriod, __wakeup) } /* }}} */ -/* {{{ date_period_is_internal_property - * Common for date_period_read_property() and date_period_write_property() functions - */ -static bool date_period_is_internal_property(zend_string *name) -{ - if (zend_string_equals_literal(name, "recurrences") - || zend_string_equals_literal(name, "include_start_date") - || zend_string_equals_literal(name, "include_end_date") - || zend_string_equals_literal(name, "start") - || zend_string_equals_literal(name, "current") - || zend_string_equals_literal(name, "end") - || zend_string_equals_literal(name, "interval") - ) { - return 1; - } - return 0; -} -/* }}} */ - /* {{{ date_period_read_property */ static zval *date_period_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) { diff --git a/ext/date/tests/DateTimeImmutable_inherited_serialization.phpt b/ext/date/tests/DateTimeImmutable_inherited_serialization.phpt new file mode 100644 index 0000000000000..a533b651eed67 --- /dev/null +++ b/ext/date/tests/DateTimeImmutable_inherited_serialization.phpt @@ -0,0 +1,23 @@ +--TEST-- +Inherited DateTimeImmutable serialisation with custom properties +--FILE-- +myProperty); +?> +--EXPECTF-- +bool(true) diff --git a/ext/date/tests/DateTimeImmutable_serialisation.phpt b/ext/date/tests/DateTimeImmutable_serialization.phpt similarity index 100% rename from ext/date/tests/DateTimeImmutable_serialisation.phpt rename to ext/date/tests/DateTimeImmutable_serialization.phpt diff --git a/ext/date/tests/DateTimeInterval_inherited_serialization.phpt b/ext/date/tests/DateTimeInterval_inherited_serialization.phpt new file mode 100644 index 0000000000000..fca8f29b901c9 --- /dev/null +++ b/ext/date/tests/DateTimeInterval_inherited_serialization.phpt @@ -0,0 +1,22 @@ +--TEST-- +Inherited DateTimeInterval serialisation with custom properties +--FILE-- +myProperty); +?> +--EXPECTF-- +bool(true) diff --git a/ext/date/tests/DateTimePeriod_inherited_serialization.phpt b/ext/date/tests/DateTimePeriod_inherited_serialization.phpt new file mode 100644 index 0000000000000..c0d94cf01ef86 --- /dev/null +++ b/ext/date/tests/DateTimePeriod_inherited_serialization.phpt @@ -0,0 +1,25 @@ +--TEST-- +Inherited DateTimePeriod serialisation with custom properties +--FILE-- +myProperty); +?> +--EXPECTF-- +bool(true) diff --git a/ext/date/tests/DateTimeZone_inherited_serialization.phpt b/ext/date/tests/DateTimeZone_inherited_serialization.phpt new file mode 100644 index 0000000000000..d70c983bae7f1 --- /dev/null +++ b/ext/date/tests/DateTimeZone_inherited_serialization.phpt @@ -0,0 +1,22 @@ +--TEST-- +Inherited DateTimeZone serialisation with custom properties +--FILE-- +myProperty); +?> +--EXPECTF-- +bool(true) diff --git a/ext/date/tests/DateTimeZone_serialisation.phpt b/ext/date/tests/DateTimeZone_serialization.phpt similarity index 100% rename from ext/date/tests/DateTimeZone_serialisation.phpt rename to ext/date/tests/DateTimeZone_serialization.phpt diff --git a/ext/date/tests/DateTime_inherited_serialization.phpt b/ext/date/tests/DateTime_inherited_serialization.phpt new file mode 100644 index 0000000000000..5e9101309457b --- /dev/null +++ b/ext/date/tests/DateTime_inherited_serialization.phpt @@ -0,0 +1,23 @@ +--TEST-- +Inherited DateTime serialisation with custom properties +--FILE-- +myProperty); +?> +--EXPECTF-- +bool(true) diff --git a/ext/date/tests/DateTime_serialisation.phpt b/ext/date/tests/DateTime_serialization.phpt similarity index 100% rename from ext/date/tests/DateTime_serialisation.phpt rename to ext/date/tests/DateTime_serialization.phpt diff --git a/ext/date/tests/bug53437_var3.phpt b/ext/date/tests/bug53437_var3.phpt index 6fd5f11f0301b..c87c5c8b9a0cd 100644 --- a/ext/date/tests/bug53437_var3.phpt +++ b/ext/date/tests/bug53437_var3.phpt @@ -4,7 +4,7 @@ Bug #53437 DateInterval unserialize bad data, 32 bit --FILE-- --FILE-- --FILE-- --EXPECTF-- diff --git a/ext/date/tests/gh10152.phpt b/ext/date/tests/gh10152.phpt new file mode 100644 index 0000000000000..7886cf90ef26b --- /dev/null +++ b/ext/date/tests/gh10152.phpt @@ -0,0 +1,23 @@ +--TEST-- +GH-10152: Custom properties of DateTimeImmutable child classes are not serialized +--FILE-- +myProperty); +?> +--EXPECT-- +bool(true) diff --git a/ext/date/tests/gh10447.phpt b/ext/date/tests/gh10447.phpt new file mode 100644 index 0000000000000..3b7ff54c97fb5 --- /dev/null +++ b/ext/date/tests/gh10447.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug GH-10447 ('p' format specifier does not yield 'Z' for 00:00) +--FILE-- +format('Y-m-d\TH:i:sp'), "\n"; + +$date = new \DateTimeImmutable('2023-01-25T00:00:00-00:00'); +echo $date->format('Y-m-d\TH:i:sp'), "\n"; +?> +--EXPECT-- +2023-01-25T00:00:00Z +2023-01-25T00:00:00Z diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index a7f9431a06cfd..0d589c7c61d0f 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -4788,6 +4788,7 @@ static int accel_finish_startup(void) } if (pid == -1) { /* no subprocess was needed */ + /* The called function unlocks the shared alloc lock */ return accel_finish_startup_preload(false); } else if (pid == 0) { /* subprocess */ int ret = accel_finish_startup_preload(true); @@ -4805,6 +4806,8 @@ static int accel_finish_startup(void) preload_load(); } + zend_shared_alloc_unlock(); + if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { return SUCCESS; } else { diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index c594ade575bed..1e6b39da26464 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -27,9 +27,14 @@ static ZEND_COLD void undef_result_after_exception(void) { } } -static ZEND_COLD void zend_jit_illegal_offset(void) +static ZEND_COLD void zend_jit_illegal_empty_or_isset_offset(const zval *offset) { - zend_type_error("Illegal offset type"); + zend_type_error("Cannot access offset of type %s in isset or empty", zend_get_type_by_const(Z_TYPE_P(offset))); +} + +static ZEND_COLD void zend_jit_illegal_array_offset(zval *offset) +{ + zend_type_error("Cannot access offset of type %s on array", zend_get_type_by_const(Z_TYPE_P(offset))); } static ZEND_COLD void zend_jit_illegal_string_offset(zval *offset) @@ -488,7 +493,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_r_helper(zend_array *ht, zval *dim, hval = 1; goto num_index; default: - zend_jit_illegal_offset(); + zend_jit_illegal_array_offset(dim); undef_result_after_exception(); return; } @@ -630,7 +635,7 @@ static void ZEND_FASTCALL zend_jit_fetch_dim_is_helper(zend_array *ht, zval *dim hval = 1; goto num_index; default: - zend_jit_illegal_offset(); + zend_jit_illegal_array_offset(dim); undef_result_after_exception(); return; } @@ -868,7 +873,7 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_rw_helper(zend_array *ht, zval *di hval = 1; goto num_index; default: - zend_jit_illegal_offset(); + zend_jit_illegal_array_offset(dim); undef_result_after_exception(); return NULL; } @@ -1001,7 +1006,7 @@ static zval* ZEND_FASTCALL zend_jit_fetch_dim_w_helper(zend_array *ht, zval *dim hval = 1; goto num_index; default: - zend_jit_illegal_offset(); + zend_jit_illegal_array_offset(dim); undef_result_after_exception(); if (EG(opline_before_exception) && (EG(opline_before_exception)+1)->opcode == ZEND_OP_DATA diff --git a/ext/opcache/tests/gh10405.inc b/ext/opcache/tests/gh10405.inc new file mode 100644 index 0000000000000..cd6cb00097caa --- /dev/null +++ b/ext/opcache/tests/gh10405.inc @@ -0,0 +1,2 @@ + +--FILE-- + +OK +--EXPECTF-- +bool(false) +included +OK diff --git a/ext/opcache/tests/jit/assign_dim_002.phpt b/ext/opcache/tests/jit/assign_dim_002.phpt index 3f713a6c6a6a9..83b4bfdec7873 100644 --- a/ext/opcache/tests/jit/assign_dim_002.phpt +++ b/ext/opcache/tests/jit/assign_dim_002.phpt @@ -161,7 +161,7 @@ array(1) { int(1) } } -Illegal offset type +Cannot access offset of type object on array array(1) { [0]=> array(2) { @@ -198,7 +198,7 @@ array(1) { } Deprecated: Automatic conversion of false to array is deprecated in %s on line %d -Illegal offset type +Cannot access offset of type array on array Deprecated: Automatic conversion of false to array is deprecated in %s on line %d int(1) @@ -221,7 +221,7 @@ array(1) { } Deprecated: Automatic conversion of false to array is deprecated in %s on line %d -Illegal offset type +Cannot access offset of type array on array Warning: Undefined variable $undef in %s on line %d NULL diff --git a/ext/opcache/tests/jit/assign_dim_op_001.phpt b/ext/opcache/tests/jit/assign_dim_op_001.phpt index a533cbe9c283b..731a2e96420a7 100644 --- a/ext/opcache/tests/jit/assign_dim_op_001.phpt +++ b/ext/opcache/tests/jit/assign_dim_op_001.phpt @@ -79,7 +79,7 @@ Warning: Undefined array key 2 in %s on line %d Deprecated: Automatic conversion of false to array is deprecated in %s on line %d Deprecated: Automatic conversion of false to array is deprecated in %s on line %d -Illegal offset type +Cannot access offset of type array on array Deprecated: Automatic conversion of false to array is deprecated in %s on line %d @@ -104,5 +104,5 @@ array(1) { } Deprecated: Automatic conversion of false to array is deprecated in %s on line %d -Illegal offset type +Cannot access offset of type array on array Unsupported operand types: null % string diff --git a/ext/opcache/tests/jit/assign_obj_op_003.phpt b/ext/opcache/tests/jit/assign_obj_op_003.phpt new file mode 100644 index 0000000000000..325583e84d912 --- /dev/null +++ b/ext/opcache/tests/jit/assign_obj_op_003.phpt @@ -0,0 +1,26 @@ +--TEST-- +JIT ASSIGN_OBJ_OP: invalid type inference +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +--FILE-- +bar += 1.3; + } catch(y) { + } + } +} +var_dump(new Foo); +?> +--EXPECTF-- +Deprecated: Implicit conversion from float 1.3 to int loses precision in %sassign_obj_op_003.php on line 6 +object(Foo)#1 (1) { + ["bar"]=> + int(1) +} diff --git a/ext/opcache/tests/jit/fetch_dim_rw_004.phpt b/ext/opcache/tests/jit/fetch_dim_rw_004.phpt index ea3fff88f1e45..d9302b8fd04ce 100644 --- a/ext/opcache/tests/jit/fetch_dim_rw_004.phpt +++ b/ext/opcache/tests/jit/fetch_dim_rw_004.phpt @@ -18,7 +18,7 @@ Stack trace: #0 %sfetch_dim_rw_004.php(5): {closure}(2, 'Undefined varia...', '%s', 5) #1 {main} -Next TypeError: Illegal offset type in %sfetch_dim_rw_004.php:5 +Next TypeError: Cannot access offset of type array on array in %sfetch_dim_rw_004.php:5 Stack trace: #0 {main} thrown in %sfetch_dim_rw_004.php on line 5 diff --git a/ext/opcache/tests/opt/inference_002.phpt b/ext/opcache/tests/opt/inference_002.phpt index 70412426c2fcc..0ac2f93627e89 100644 --- a/ext/opcache/tests/opt/inference_002.phpt +++ b/ext/opcache/tests/opt/inference_002.phpt @@ -9,7 +9,8 @@ opcache.optimization_level=-1 var_dump([[]=>&$x]); ?> --EXPECTF-- -Fatal error: Uncaught TypeError: Illegal offset type in %sinference_002.php:2 +Fatal error: Uncaught TypeError: Cannot access offset of type array on array in %sinference_002.php:2 Stack trace: #0 {main} - thrown in %sinference_002.php on line 2 \ No newline at end of file + thrown in %sinference_002.php on line 2 + diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 3b2e4c2ca76aa..1edc008344990 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -478,14 +478,15 @@ int phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, char *alia return FAILURE; } + uint32_t entry_mode = phar_tar_number(hdr->mode, sizeof(hdr->mode)); entry.tar_type = ((old & (hdr->typeflag == '\0')) ? TAR_FILE : hdr->typeflag); entry.offset = entry.offset_abs = pos; /* header_offset unused in tar */ entry.fp_type = PHAR_FP; - entry.flags = phar_tar_number(hdr->mode, sizeof(hdr->mode)) & PHAR_ENT_PERM_MASK; + entry.flags = entry_mode & PHAR_ENT_PERM_MASK; entry.timestamp = phar_tar_number(hdr->mtime, sizeof(hdr->mtime)); entry.is_persistent = myphar->is_persistent; - if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry.flags)) { + if (old && entry.tar_type == TAR_FILE && S_ISDIR(entry_mode)) { entry.tar_type = TAR_DIR; } diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c index ef32661be09ff..82672e68f2bab 100644 --- a/ext/sockets/multicast.c +++ b/ext/sockets/multicast.c @@ -59,7 +59,7 @@ static const char *_php_source_op_to_string(enum source_op sop); static int _php_source_op_to_ipv4_op(enum source_op sop); #endif -int php_string_to_if_index(const char *val, unsigned *out) +zend_result php_string_to_if_index(const char *val, unsigned *out) { #if HAVE_IF_NAMETOINDEX unsigned int ind; @@ -81,7 +81,7 @@ int php_string_to_if_index(const char *val, unsigned *out) #endif } -static int php_get_if_index_from_zval(zval *val, unsigned *out) +static zend_result php_get_if_index_from_zval(zval *val, unsigned *out) { int ret; @@ -104,7 +104,7 @@ static int php_get_if_index_from_zval(zval *val, unsigned *out) -static int php_get_if_index_from_array(const HashTable *ht, const char *key, +static zend_result php_get_if_index_from_array(const HashTable *ht, const char *key, php_socket *sock, unsigned int *if_index) { zval *val; @@ -117,7 +117,7 @@ static int php_get_if_index_from_array(const HashTable *ht, const char *key, return php_get_if_index_from_zval(val, if_index); } -static int php_get_address_from_array(const HashTable *ht, const char *key, +static zend_result php_get_address_from_array(const HashTable *ht, const char *key, php_socket *sock, php_sockaddr_storage *ss, socklen_t *ss_len) { zval *val; @@ -136,7 +136,7 @@ static int php_get_address_from_array(const HashTable *ht, const char *key, return SUCCESS; } -static int php_do_mcast_opt(php_socket *php_sock, int level, int optname, zval *arg4) +static zend_result php_do_mcast_opt(php_socket *php_sock, int level, int optname, zval *arg4) { HashTable *opt_ht; unsigned int if_index; @@ -616,7 +616,7 @@ static int _php_source_op_to_ipv4_op(enum source_op sop) #endif /* HAS_MCAST_EXT */ #ifdef PHP_WIN32 -int php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_addr *out_addr) +zend_result php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_addr *out_addr) { MIB_IPADDRTABLE *addr_table; ULONG size; @@ -659,7 +659,7 @@ int php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_add return FAILURE; } -int php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *if_index) +zend_result php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *if_index) { MIB_IPADDRTABLE *addr_table; ULONG size; @@ -709,7 +709,7 @@ int php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *i #else -int php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_addr *out_addr) +zend_result php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_addr *out_addr) { struct ifreq if_req; @@ -746,7 +746,7 @@ int php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_add return SUCCESS; } -int php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *if_index) +zend_result php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *if_index) { struct ifconf if_conf = {0}; char *buf = NULL, diff --git a/ext/sockets/multicast.h b/ext/sockets/multicast.h index 1e7a0daeb2f20..0362b269728f1 100644 --- a/ext/sockets/multicast.h +++ b/ext/sockets/multicast.h @@ -51,17 +51,17 @@ int php_do_setsockopt_ipv6_mcast(php_socket *php_sock, int optname, zval *arg4); -int php_if_index_to_addr4( +zend_result php_if_index_to_addr4( unsigned if_index, php_socket *php_sock, struct in_addr *out_addr); -int php_add4_to_if_index( +zend_result php_add4_to_if_index( struct in_addr *addr, php_socket *php_sock, unsigned *if_index); -int php_string_to_if_index(const char *val, unsigned *out); +zend_result php_string_to_if_index(const char *val, unsigned *out); int php_mcast_join( php_socket *sock, diff --git a/ext/sockets/php_sockets.h b/ext/sockets/php_sockets.h index fdbc636538cf7..93eba9da0731a 100644 --- a/ext/sockets/php_sockets.h +++ b/ext/sockets/php_sockets.h @@ -126,7 +126,7 @@ enum sockopt_return { }; PHP_SOCKETS_API char *sockets_strerror(int error); -PHP_SOCKETS_API int socket_import_file_descriptor(PHP_SOCKET socket, php_socket *retsock); +PHP_SOCKETS_API bool socket_import_file_descriptor(PHP_SOCKET socket, php_socket *retsock); #else #define phpext_sockets_ptr NULL diff --git a/ext/sockets/sockaddr_conv.c b/ext/sockets/sockaddr_conv.c index 6ec540931f725..e4a7347cafab3 100644 --- a/ext/sockets/sockaddr_conv.c +++ b/ext/sockets/sockaddr_conv.c @@ -9,7 +9,7 @@ #include #endif -extern int php_string_to_if_index(const char *val, unsigned *out); +extern zend_result php_string_to_if_index(const char *val, unsigned *out); #if HAVE_IPV6 /* Sets addr by hostname, or by ip in string form (AF_INET6) */ diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 573b3976701f6..b73166f75a8c5 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -223,7 +223,7 @@ ZEND_GET_MODULE(sockets) int inet_ntoa_lock = 0; #endif -static int php_open_listen_sock(php_socket *sock, int port, int backlog) /* {{{ */ +static bool php_open_listen_sock(php_socket *sock, int port, int backlog) /* {{{ */ { struct sockaddr_in la; struct hostent *hp; @@ -266,7 +266,7 @@ static int php_open_listen_sock(php_socket *sock, int port, int backlog) /* {{{ } /* }}} */ -static int php_accept_connect(php_socket *in_sock, php_socket *out_sock, struct sockaddr *la, socklen_t *la_len) /* {{{ */ +static bool php_accept_connect(php_socket *in_sock, php_socket *out_sock, struct sockaddr *la, socklen_t *la_len) /* {{{ */ { out_sock->bsd_socket = accept(in_sock->bsd_socket, la, la_len); @@ -526,14 +526,13 @@ static int php_sock_array_to_fd_set(uint32_t arg_num, zval *sock_array, fd_set * } /* }}} */ -static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds) /* {{{ */ +static void php_sock_array_from_fd_set(zval *sock_array, fd_set *fds) /* {{{ */ { zval *element; zval *dest_element; php_socket *php_sock; zval new_hash; - int num = 0; - zend_ulong num_key; + zend_ulong num_key; zend_string *key; ZEND_ASSERT(Z_TYPE_P(sock_array) == IS_ARRAY); @@ -557,15 +556,12 @@ static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds) /* {{{ */ Z_ADDREF_P(dest_element); } } - num++; } ZEND_HASH_FOREACH_END(); /* Destroy old array, add new one */ zval_ptr_dtor(sock_array); ZVAL_COPY_VALUE(sock_array, &new_hash); - - return num ? 1 : 0; } /* }}} */ @@ -2179,7 +2175,7 @@ PHP_FUNCTION(socket_clear_error) } /* }}} */ -int socket_import_file_descriptor(PHP_SOCKET socket, php_socket *retsock) +bool socket_import_file_descriptor(PHP_SOCKET socket, php_socket *retsock) { #ifdef SO_DOMAIN int type; diff --git a/ext/sockets/sockets.stub.php b/ext/sockets/sockets.stub.php index 2db842810a611..82969270fb846 100644 --- a/ext/sockets/sockets.stub.php +++ b/ext/sockets/sockets.stub.php @@ -1525,6 +1525,13 @@ * @cvalue IPPROTO_UDP */ const SOL_UDP = UNKNOWN; +#ifdef IPPROTO_UDPLITE +/** + * @var int + * @cvalue IPPROTO_UDPLITE + */ +const SOL_UDPLITE = UNKNOWN; +#endif #if HAVE_IPV6 /** @@ -1769,6 +1776,20 @@ */ const IP_PMTUDISC_OMIT = UNKNOWN; #endif +#if defined(UDPLITE_SEND_CSCOV) +/** + * @var int + * @cvalue UDPLITE_SEND_CSCOV + */ +const UDPLITE_SEND_CSCOV = UNKNOWN; +#endif +#if defined(UDPLITE_RECV_CSCOV) +/** + * @var int + * @cvalue UDPLITE_RECV_CSCOV + */ +const UDPLITE_RECV_CSCOV = UNKNOWN; +#endif /** * @strict-properties diff --git a/ext/sockets/sockets_arginfo.h b/ext/sockets/sockets_arginfo.h index eca944ba52136..f630d829f4cd6 100644 --- a/ext/sockets/sockets_arginfo.h +++ b/ext/sockets/sockets_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: bf1d22072bd147128a33d82f8b3fc441cf95156a */ + * Stub hash: d02c3c772eab5d9c1310839d2464887993f8e8de */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_select, 0, 4, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(1, read, IS_ARRAY, 1) @@ -915,6 +915,9 @@ static void register_sockets_symbols(int module_number) #endif REGISTER_LONG_CONSTANT("SOL_TCP", IPPROTO_TCP, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SOL_UDP", IPPROTO_UDP, CONST_PERSISTENT); +#if defined(IPPROTO_UDPLITE) + REGISTER_LONG_CONSTANT("SOL_UDPLITE", IPPROTO_UDPLITE, CONST_PERSISTENT); +#endif #if HAVE_IPV6 REGISTER_LONG_CONSTANT("IPV6_UNICAST_HOPS", IPV6_UNICAST_HOPS, CONST_PERSISTENT); #endif @@ -1018,6 +1021,12 @@ static void register_sockets_symbols(int module_number) #if defined(IP_PMTUDISC_OMIT) REGISTER_LONG_CONSTANT("IP_PMTUDISC_OMIT", IP_PMTUDISC_OMIT, CONST_PERSISTENT); #endif +#if defined(UDPLITE_SEND_CSCOV) + REGISTER_LONG_CONSTANT("UDPLITE_SEND_CSCOV", UDPLITE_SEND_CSCOV, CONST_PERSISTENT); +#endif +#if defined(UDPLITE_RECV_CSCOV) + REGISTER_LONG_CONSTANT("UDPLITE_RECV_CSCOV", UDPLITE_RECV_CSCOV, CONST_PERSISTENT); +#endif } static zend_class_entry *register_class_Socket(void) diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 4098382c61c17..9b6218f7404f5 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -286,7 +286,7 @@ static zend_result get_hash_key(spl_hash_key *key, spl_array_object *intern, zva ZVAL_DEREF(offset); goto try_again; default: - zend_type_error("Illegal offset type"); + zend_illegal_array_offset(offset); return FAILURE; } @@ -313,7 +313,7 @@ static zval *spl_array_get_dimension_ptr(int check_inherited, spl_array_object * } if (get_hash_key(&key, intern, offset) == FAILURE) { - zend_type_error("Illegal offset type"); + zend_illegal_array_offset(offset); return (type == BP_VAR_W || type == BP_VAR_RW) ? &EG(error_zval) : &EG(uninitialized_zval); } @@ -466,7 +466,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zend_object *objec } if (get_hash_key(&key, intern, offset) == FAILURE) { - zend_type_error("Illegal offset type"); + zend_illegal_array_offset(offset); zval_ptr_dtor(value); return; } @@ -502,7 +502,7 @@ static void spl_array_unset_dimension_ex(int check_inherited, zend_object *objec } if (get_hash_key(&key, intern, offset) == FAILURE) { - zend_type_error("Illegal offset type in unset"); + zend_illegal_unset_offset(offset); return; } @@ -566,7 +566,7 @@ static bool spl_array_has_dimension_ex(bool check_inherited, zend_object *object spl_hash_key key; if (get_hash_key(&key, intern, offset) == FAILURE) { - zend_type_error("Illegal offset type in isset or empty"); + zend_illegal_empty_or_isset_offset(offset); return 0; } diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 465c649e980aa..b05a5cc3dbcff 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -333,7 +333,7 @@ static zend_long spl_offset_convert_to_long(zval *offset) /* {{{ */ return Z_RES_HANDLE_P(offset); } - zend_type_error("Illegal offset type"); + zend_illegal_array_offset(offset); return 0; } diff --git a/ext/spl/tests/ArrayObject_illegal_offset.phpt b/ext/spl/tests/ArrayObject_illegal_offset.phpt index df25e4fa5e0fa..c21c93781a471 100644 --- a/ext/spl/tests/ArrayObject_illegal_offset.phpt +++ b/ext/spl/tests/ArrayObject_illegal_offset.phpt @@ -32,8 +32,8 @@ try { ?> --EXPECT-- -Illegal offset type -Illegal offset type -Illegal offset type -Illegal offset type in isset or empty -Illegal offset type in unset +Cannot access offset of type array on array +Cannot access offset of type array on array +Cannot access offset of type array on array +Cannot access offset of type array in isset or empty +Cannot access offset of type array on unset diff --git a/ext/spl/tests/fixedarray_001.phpt b/ext/spl/tests/fixedarray_001.phpt index a6ab149c75ca5..c1ebf23b1b07f 100644 --- a/ext/spl/tests/fixedarray_001.phpt +++ b/ext/spl/tests/fixedarray_001.phpt @@ -46,7 +46,7 @@ var_dump($b[0]); ?> --EXPECT-- RuntimeException: Index invalid or out of range -TypeError: Illegal offset type +TypeError: Cannot access offset of type string on array RuntimeException: Index invalid or out of range string(6) "value0" string(6) "value2" diff --git a/ext/spl/tests/fixedarray_002.phpt b/ext/spl/tests/fixedarray_002.phpt index 4f6682e6df3a0..93d10770583ec 100644 --- a/ext/spl/tests/fixedarray_002.phpt +++ b/ext/spl/tests/fixedarray_002.phpt @@ -71,7 +71,7 @@ var_dump(count($a), $a->getSize(), count($a) == $a->getSize()); A::offsetSet RuntimeException: Index invalid or out of range A::offsetGet -TypeError: Illegal offset type +TypeError: Cannot access offset of type string on array A::offsetUnset RuntimeException: Index invalid or out of range A::offsetSet diff --git a/ext/spl/tests/fixedarray_003.phpt b/ext/spl/tests/fixedarray_003.phpt index 277088d04f045..bbd5211dca029 100644 --- a/ext/spl/tests/fixedarray_003.phpt +++ b/ext/spl/tests/fixedarray_003.phpt @@ -168,55 +168,55 @@ try { Write context Deprecated: Implicit conversion from float 2.5 to int loses precision in %s on line %d -Illegal offset type -Illegal offset type +Cannot access offset of type array on array +Cannot access offset of type object on array Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d -Illegal offset type -Illegal offset type -Illegal offset type +Cannot access offset of type string on array +Cannot access offset of type string on array +Cannot access offset of type string on array Read context string(1) "a" string(1) "b" Deprecated: Implicit conversion from float 2.5 to int loses precision in %s on line %d string(1) "c" -Illegal offset type -Illegal offset type +Cannot access offset of type array on array +Cannot access offset of type object on array Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d string(1) "f" string(1) "g" -Illegal offset type -Illegal offset type -Illegal offset type +Cannot access offset of type string on array +Cannot access offset of type string on array +Cannot access offset of type string on array isset() bool(true) bool(true) Deprecated: Implicit conversion from float 2.5 to int loses precision in %s on line %d bool(true) -Illegal offset type -Illegal offset type +Cannot access offset of type array on array +Cannot access offset of type object on array Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d bool(true) bool(true) -Illegal offset type -Illegal offset type -Illegal offset type +Cannot access offset of type string on array +Cannot access offset of type string on array +Cannot access offset of type string on array empty() bool(false) bool(false) Deprecated: Implicit conversion from float 2.5 to int loses precision in %s on line %d bool(false) -Illegal offset type -Illegal offset type +Cannot access offset of type array on array +Cannot access offset of type object on array Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d bool(false) bool(false) -Illegal offset type -Illegal offset type -Illegal offset type +Cannot access offset of type string on array +Cannot access offset of type string on array +Cannot access offset of type string on array diff --git a/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt b/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt index f3460bfccca77..44b4e2a0ebcbb 100644 --- a/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt +++ b/ext/spl/tests/iterator_to_array_nonscalar_keys.phpt @@ -21,4 +21,4 @@ try { ?> --EXPECTF-- Deprecated: Implicit conversion from float 2.5 to int loses precision in %s on line %d -Illegal offset type +Cannot access offset of type array on array diff --git a/ext/standard/tests/array/array_key_exists.phpt b/ext/standard/tests/array/array_key_exists.phpt index d6f9ca13de718..8cc2f9c5207c2 100644 --- a/ext/standard/tests/array/array_key_exists.phpt +++ b/ext/standard/tests/array/array_key_exists.phpt @@ -202,7 +202,7 @@ bool(false) bool(true) *** Testing error conditions *** -Illegal offset type +Cannot access offset of type array on array *** Testing operation on objects *** array_key_exists(): Argument #2 ($array) must be of type array, key_check given diff --git a/ext/standard/tests/array/array_key_exists_variation1.phpt b/ext/standard/tests/array/array_key_exists_variation1.phpt index 3a410258bb999..eb35d1bfae0c1 100644 --- a/ext/standard/tests/array/array_key_exists_variation1.phpt +++ b/ext/standard/tests/array/array_key_exists_variation1.phpt @@ -129,7 +129,7 @@ bool(false) bool(false) -- Iteration 13 -- -Illegal offset type +Cannot access offset of type array on array -- Iteration 14 -- bool(true) @@ -141,7 +141,7 @@ bool(true) bool(true) -- Iteration 17 -- -Illegal offset type +Cannot access offset of type object on array -- Iteration 18 -- bool(false) diff --git a/ext/standard/tests/array/bug68553.phpt b/ext/standard/tests/array/bug68553.phpt index dbb74c7994bb3..7325a68da5413 100644 --- a/ext/standard/tests/array/bug68553.phpt +++ b/ext/standard/tests/array/bug68553.phpt @@ -79,5 +79,5 @@ array(8) { NULL } } -Illegal offset type -Illegal offset type +Cannot access offset of type object on array +Cannot access offset of type array on array diff --git a/tests/classes/tostring_001.phpt b/tests/classes/tostring_001.phpt index abf41f97cdaca..ddbe4d152dde0 100644 --- a/tests/classes/tostring_001.phpt +++ b/tests/classes/tostring_001.phpt @@ -118,7 +118,7 @@ test2::__toString() Converted ====test7==== test2::__toString() -Illegal offset type +Cannot access offset of type object on array ====test8==== test2::__toString() string(9) "Converted"