Skip to content

Commit bb66f38

Browse files
committed
Merge remote-tracking branch 'origin/master' into native-tls
* origin/master: (37 commits) NEWS NEWS Fix bug #68601 buffer read overflow in gd_gif_in.c Fixed compilation warnings Removed unnecessary checks pcntl_signal_dispatch: Speed up by preventing system calls when unnecessary Merged PR php#911. Removed ZEND_ACC_FINAL_CLASS which is unnecessary. This also fixed some currently defined classes as final which were just not being considered as such before. Updated NEWS Updated NEWS Updated NEWS Fix bug #68532: convert.base64-encode omits padding bytes Updated NEWS Updated NEWS Updated NEWS Fixed Bug #65576 (Constructor from trait conflicts with inherited constructor) Updated NEWS Updated NEWS Fix MySQLi tests Fixed gd test ...
2 parents dfb18b1 + 0ea0b59 commit bb66f38

File tree

118 files changed

+614
-437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+614
-437
lines changed

NEWS

+8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ PHP NEWS
2222
classes (https://wiki.php.net/rfc/secure_unserialize). (Stas)
2323
. Fixed bug #68185 ("Inconsistent insteadof definition."- incorrectly triggered). (Julien)
2424
. Fixed bug #65419 (Inside trait, self::class != __CLASS__). (Julien)
25+
. Fixed bug #65576 (Constructor from trait conflicts with inherited
26+
constructor). (dunglas at gmail dot com)
27+
. Removed ZEND_ACC_FINAL_CLASS, promoting ZEND_ACC_FINAL as final class
28+
modifier. (Guilherme Blanco)
2529

2630
- Date:
2731
. Fixed day_of_week function as it could sometimes return negative values
@@ -82,6 +86,10 @@ PHP NEWS
8286
. Added intdiv() function. (Andrea)
8387
. Improved precision of log() function for base 2 and 10. (Marc Bennewitz)
8488

89+
- Streams:
90+
. Fixed bug #68532 (convert.base64-encode omits padding bytes).
91+
(blaesius at krumedia dot de)
92+
8593
- XSL:
8694
. Fixed bug #64776 (The XSLT extension is not thread safe). (Mike)
8795

UPGRADING.INTERNALS

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ PHP 7.0 INTERNALS UPGRADE NOTES
1313
l. get_class_name object handler info
1414
m. Other portable macros info
1515
n. ZEND_ENGINE_2 removal
16+
o. Updated final class modifier
1617

1718
2. Build system changes
1819
a. Unix build system changes
@@ -123,6 +124,9 @@ PHP 7.0 INTERNALS UPGRADE NOTES
123124
ZEND_NORETURN is defined as __declspec(noreturn) on VS
124125

125126
n. The ZEND_ENGINE_2 macro has been removed. A ZEND_ENGINE_3 macro has been added.
127+
128+
o. Removed ZEND_ACC_FINAL_CLASS in favour of ZEND_ACC_FINAL, turning final class
129+
modifier now a different class entry flag. Update your extensions.
126130

127131
========================
128132
2. Build system changes

Zend/tests/traits/bug65576a.phpt

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Bug #65576 (Constructor from trait conflicts with inherited constructor)
3+
--FILE--
4+
<?php
5+
6+
trait T
7+
{
8+
public function __construct()
9+
{
10+
echo "Trait contructor\n";
11+
}
12+
}
13+
14+
class A
15+
{
16+
public function __construct()
17+
{
18+
echo "Parent constructor\n";
19+
}
20+
}
21+
22+
class B extends A
23+
{
24+
use T;
25+
}
26+
27+
new B();
28+
29+
--EXPECT--
30+
Trait contructor
31+

Zend/tests/traits/bug65576b.phpt

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #65576 (Constructor from trait conflicts with inherited constructor)
3+
--FILE--
4+
<?php
5+
6+
trait T
7+
{
8+
public function __construct()
9+
{
10+
parent::__construct();
11+
echo "Trait contructor\n";
12+
}
13+
}
14+
15+
class A
16+
{
17+
public function __construct()
18+
{
19+
echo "Parent constructor\n";
20+
}
21+
}
22+
23+
class B extends A
24+
{
25+
use T;
26+
}
27+
28+
new B();
29+
30+
--EXPECT--
31+
Parent constructor
32+
Trait contructor
33+

Zend/zend_API.c

+20-16
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,16 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
404404
if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), p, &d, -1)) == 0) {
405405
return "long";
406406
} else if (type == IS_DOUBLE) {
407-
if (c == 'L') {
408-
if (d > ZEND_LONG_MAX) {
409-
*p = ZEND_LONG_MAX;
410-
break;
411-
} else if (d < ZEND_LONG_MIN) {
412-
*p = ZEND_LONG_MIN;
413-
break;
407+
if (zend_isnan(d)) {
408+
return "long";
409+
}
410+
if (!ZEND_DOUBLE_FITS_LONG(d)) {
411+
if (c == 'L') {
412+
*p = (d > 0) ? ZEND_LONG_MAX : ZEND_LONG_MIN;
413+
} else {
414+
return "long";
414415
}
416+
break;
415417
}
416418

417419
*p = zend_dval_to_lval(d);
@@ -420,14 +422,16 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
420422
break;
421423

422424
case IS_DOUBLE:
423-
if (c == 'L') {
424-
if (Z_DVAL_P(arg) > ZEND_LONG_MAX) {
425-
*p = ZEND_LONG_MAX;
426-
break;
427-
} else if (Z_DVAL_P(arg) < ZEND_LONG_MIN) {
428-
*p = ZEND_LONG_MIN;
429-
break;
425+
if (zend_isnan(Z_DVAL_P(arg))) {
426+
return "long";
427+
}
428+
if (!ZEND_DOUBLE_FITS_LONG(Z_DVAL_P(arg))) {
429+
if (c == 'L') {
430+
*p = (Z_DVAL_P(arg) > 0) ? ZEND_LONG_MAX : ZEND_LONG_MIN;
431+
} else {
432+
return "long";
430433
}
434+
break;
431435
}
432436
case IS_NULL:
433437
case IS_FALSE:
@@ -1127,7 +1131,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties TSRMLS_DC)
11271131
}
11281132
/* }}} */
11291133

1130-
static int zval_update_class_constant(zval *pp, int is_static, int offset TSRMLS_DC) /* {{{ */
1134+
static int zval_update_class_constant(zval *pp, int is_static, uint32_t offset TSRMLS_DC) /* {{{ */
11311135
{
11321136
ZVAL_DEREF(pp);
11331137
if (Z_CONSTANT_P(pp)) {
@@ -2195,7 +2199,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
21952199
internal_function->arg_info = (zend_internal_arg_info*)ptr->arg_info+1;
21962200
internal_function->num_args = ptr->num_args;
21972201
/* Currently you cannot denote that the function can accept less arguments than num_args */
2198-
if (info->required_num_args == -1) {
2202+
if (info->required_num_args == (zend_uintptr_t)-1) {
21992203
internal_function->required_num_args = ptr->num_args;
22002204
} else {
22012205
internal_function->required_num_args = info->required_num_args;

Zend/zend_API.h

+20-9
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ ZEND_API zend_array *zend_rebuild_symbol_table(TSRMLS_D);
525525
ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data);
526526
ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data);
527527
ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force TSRMLS_DC);
528-
ZEND_API int zend_set_local_var_str(const char *name, int len, zval *value, int force TSRMLS_DC);
528+
ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force TSRMLS_DC);
529529

530530
ZEND_API zend_string *zend_find_alias_name(zend_class_entry *ce, zend_string *name);
531531
ZEND_API zend_string *zend_resolve_method_name(zend_class_entry *ce, zend_function *f);
@@ -1064,10 +1064,16 @@ static zend_always_inline int _z_param_long(zval *arg, zend_long *dest, zend_boo
10641064
if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
10651065
*dest = Z_LVAL_P(arg);
10661066
} else if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
1067-
if (strict && UNEXPECTED(Z_DVAL_P(arg) > ZEND_LONG_MAX)) {
1068-
*dest = ZEND_LONG_MAX;
1069-
} else if (strict && UNEXPECTED(Z_DVAL_P(arg) < ZEND_LONG_MIN)) {
1070-
*dest = ZEND_LONG_MIN;
1067+
if (UNEXPECTED(zend_isnan(Z_DVAL_P(arg)))) {
1068+
return 0;
1069+
}
1070+
if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(Z_DVAL_P(arg)))) {
1071+
/* Ironically, the strict parameter makes zpp *non*-strict here */
1072+
if (strict) {
1073+
*dest = (Z_DVAL_P(arg) > 0) ? ZEND_LONG_MAX : ZEND_LONG_MIN;
1074+
} else {
1075+
return 0;
1076+
}
10711077
} else {
10721078
*dest = zend_dval_to_lval(Z_DVAL_P(arg));
10731079
}
@@ -1077,10 +1083,15 @@ static zend_always_inline int _z_param_long(zval *arg, zend_long *dest, zend_boo
10771083

10781084
if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_LONG)) {
10791085
if (EXPECTED(type != 0)) {
1080-
if (strict && UNEXPECTED(d > ZEND_LONG_MAX)) {
1081-
*dest = ZEND_LONG_MAX;
1082-
} else if (strict && UNEXPECTED(d < ZEND_LONG_MIN)) {
1083-
*dest = ZEND_LONG_MIN;
1086+
if (UNEXPECTED(zend_isnan(d))) {
1087+
return 0;
1088+
}
1089+
if (UNEXPECTED(!ZEND_DOUBLE_FITS_LONG(d))) {
1090+
if (strict) {
1091+
*dest = (d > 0) ? ZEND_LONG_MAX : ZEND_LONG_MIN;
1092+
} else {
1093+
return 0;
1094+
}
10841095
} else {
10851096
*dest = zend_dval_to_lval(d);
10861097
}

Zend/zend_closures.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ static const zend_function_entry closure_functions[] = {
436436
ZEND_ME(Closure, bind, arginfo_closure_bind, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
437437
ZEND_MALIAS(Closure, bindTo, bind, arginfo_closure_bindto, ZEND_ACC_PUBLIC)
438438
ZEND_ME(Closure, call, arginfo_closure_call, ZEND_ACC_PUBLIC)
439-
{NULL, NULL, NULL}
439+
ZEND_FE_END
440440
};
441441

442442
void zend_register_closure_ce(TSRMLS_D) /* {{{ */
@@ -445,7 +445,7 @@ void zend_register_closure_ce(TSRMLS_D) /* {{{ */
445445

446446
INIT_CLASS_ENTRY(ce, "Closure", closure_functions);
447447
zend_ce_closure = zend_register_internal_class(&ce TSRMLS_CC);
448-
zend_ce_closure->ce_flags |= ZEND_ACC_FINAL_CLASS;
448+
zend_ce_closure->ce_flags |= ZEND_ACC_FINAL;
449449
zend_ce_closure->create_object = zend_closure_new;
450450
zend_ce_closure->serialize = zend_class_serialize_deny;
451451
zend_ce_closure->unserialize = zend_class_unserialize_deny;

Zend/zend_compile.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ void zend_do_early_binding(TSRMLS_D) /* {{{ */
10331033
if (CG(compiler_options) & ZEND_COMPILE_DELAYED_BINDING) {
10341034
uint32_t *opline_num = &CG(active_op_array)->early_binding;
10351035

1036-
while (*opline_num != -1) {
1036+
while (*opline_num != (uint32_t)-1) {
10371037
opline_num = &CG(active_op_array)->opcodes[*opline_num].result.opline_num;
10381038
}
10391039
*opline_num = opline - CG(active_op_array)->opcodes;
@@ -1074,13 +1074,13 @@ void zend_do_early_binding(TSRMLS_D) /* {{{ */
10741074

10751075
ZEND_API void zend_do_delayed_early_binding(const zend_op_array *op_array TSRMLS_DC) /* {{{ */
10761076
{
1077-
if (op_array->early_binding != -1) {
1077+
if (op_array->early_binding != (uint32_t)-1) {
10781078
zend_bool orig_in_compilation = CG(in_compilation);
10791079
uint32_t opline_num = op_array->early_binding;
10801080
zend_class_entry *ce;
10811081

10821082
CG(in_compilation) = 1;
1083-
while (opline_num != -1) {
1083+
while (opline_num != (uint32_t)-1) {
10841084
if ((ce = zend_lookup_class(Z_STR_P(RT_CONSTANT(op_array, op_array->opcodes[opline_num-1].op2)) TSRMLS_CC)) != NULL) {
10851085
do_bind_inherited_class(op_array, &op_array->opcodes[opline_num], EG(class_table), ce, 0 TSRMLS_CC);
10861086
}
@@ -1973,7 +1973,7 @@ static zend_op *zend_compile_simple_var_no_cv(znode *result, zend_ast *ast, uint
19731973

19741974
/* there is a chance someone is accessing $this */
19751975
if (ast->kind != ZEND_AST_ZVAL
1976-
&& CG(active_op_array)->scope && CG(active_op_array)->this_var == -1
1976+
&& CG(active_op_array)->scope && CG(active_op_array)->this_var == (uint32_t)-1
19771977
) {
19781978
zend_string *key = zend_string_init("this", sizeof("this") - 1, 0);
19791979
CG(active_op_array)->this_var = lookup_cv(CG(active_op_array), key TSRMLS_CC);

Zend/zend_compile.h

-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ typedef struct _zend_try_catch_element {
182182
/* ZEND_ACC_EXPLICIT_ABSTRACT_CLASS denotes that a class was explicitly defined as abstract by using the keyword. */
183183
#define ZEND_ACC_IMPLICIT_ABSTRACT_CLASS 0x10
184184
#define ZEND_ACC_EXPLICIT_ABSTRACT_CLASS 0x20
185-
#define ZEND_ACC_FINAL_CLASS 0x40
186185
#define ZEND_ACC_INTERFACE 0x80
187186
#define ZEND_ACC_TRAIT 0x120
188187

Zend/zend_exceptions.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_exception___construct, 0, 0, 0)
664664
ZEND_ARG_INFO(0, previous)
665665
ZEND_END_ARG_INFO()
666666

667-
const static zend_function_entry default_exception_functions[] = {
667+
static const zend_function_entry default_exception_functions[] = {
668668
ZEND_ME(exception, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
669669
ZEND_ME(exception, __construct, arginfo_exception___construct, ZEND_ACC_PUBLIC)
670670
ZEND_ME(exception, getMessage, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
@@ -675,7 +675,7 @@ const static zend_function_entry default_exception_functions[] = {
675675
ZEND_ME(exception, getPrevious, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
676676
ZEND_ME(exception, getTraceAsString, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
677677
ZEND_ME(exception, __toString, NULL, 0)
678-
{NULL, NULL, NULL}
678+
ZEND_FE_END
679679
};
680680

681681
ZEND_BEGIN_ARG_INFO_EX(arginfo_error_exception___construct, 0, 0, 0)
@@ -690,7 +690,7 @@ ZEND_END_ARG_INFO()
690690
static const zend_function_entry error_exception_functions[] = {
691691
ZEND_ME(error_exception, __construct, arginfo_error_exception___construct, ZEND_ACC_PUBLIC)
692692
ZEND_ME(error_exception, getSeverity, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
693-
{NULL, NULL, NULL}
693+
ZEND_FE_END
694694
};
695695
/* }}} */
696696

Zend/zend_execute.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ static zend_always_inline zval *zend_fetch_dimension_address_inner(HashTable *ht
11681168
return retval;
11691169
}
11701170

1171-
static zend_never_inline zend_long zend_check_string_offset(zval *container, zval *dim, int type TSRMLS_DC)
1171+
static zend_never_inline zend_long zend_check_string_offset(zval *dim, int type TSRMLS_DC)
11721172
{
11731173
zend_long offset;
11741174

@@ -1211,7 +1211,7 @@ static zend_never_inline zend_long zend_check_string_offset(zval *container, zva
12111211

12121212
static zend_always_inline zend_long zend_fetch_string_offset(zval *container, zval *dim, int type TSRMLS_DC)
12131213
{
1214-
zend_long offset = zend_check_string_offset(container, dim, type TSRMLS_CC);
1214+
zend_long offset = zend_check_string_offset(dim, type TSRMLS_CC);
12151215

12161216
if (Z_REFCOUNTED_P(container)) {
12171217
if (Z_REFCOUNT_P(container) > 1) {
@@ -1250,7 +1250,7 @@ static zend_always_inline void zend_fetch_dimension_address(zval *result, zval *
12501250
goto fetch_from_array;
12511251
}
12521252

1253-
zend_check_string_offset(container, dim, type TSRMLS_CC);
1253+
zend_check_string_offset(dim, type TSRMLS_CC);
12541254

12551255
ZVAL_INDIRECT(result, NULL); /* wrong string offset */
12561256
} else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
@@ -1666,12 +1666,12 @@ static zend_always_inline void i_init_func_execute_data(zend_execute_data *execu
16661666
} while (var != end);
16671667
}
16681668

1669-
if (op_array->this_var != -1 && Z_OBJ(EX(This))) {
1669+
if (op_array->this_var != (uint32_t)-1 && EXPECTED(Z_OBJ(EX(This)))) {
16701670
ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
16711671
GC_REFCOUNT(Z_OBJ(EX(This)))++;
16721672
}
16731673

1674-
if (!op_array->run_time_cache && op_array->last_cache_slot) {
1674+
if (UNEXPECTED(!op_array->run_time_cache)) {
16751675
op_array->run_time_cache = zend_arena_calloc(&CG(arena), op_array->last_cache_slot, sizeof(void*));
16761676
}
16771677
EX_LOAD_RUN_TIME_CACHE(op_array);
@@ -1691,12 +1691,12 @@ static zend_always_inline void i_init_code_execute_data(zend_execute_data *execu
16911691

16921692
zend_attach_symbol_table(execute_data);
16931693

1694-
if (op_array->this_var != -1 && Z_OBJ(EX(This))) {
1694+
if (op_array->this_var != (uint32_t)-1 && EXPECTED(Z_OBJ(EX(This)))) {
16951695
ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
16961696
GC_REFCOUNT(Z_OBJ(EX(This)))++;
16971697
}
16981698

1699-
if (!op_array->run_time_cache && op_array->last_cache_slot) {
1699+
if (!op_array->run_time_cache) {
17001700
op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*));
17011701
}
17021702
EX_LOAD_RUN_TIME_CACHE(op_array);
@@ -1762,12 +1762,12 @@ static zend_always_inline void i_init_execute_data(zend_execute_data *execute_da
17621762
}
17631763
}
17641764

1765-
if (op_array->this_var != -1 && Z_OBJ(EX(This))) {
1765+
if (op_array->this_var != (uint32_t)-1 && EXPECTED(Z_OBJ(EX(This)))) {
17661766
ZVAL_OBJ(EX_VAR(op_array->this_var), Z_OBJ(EX(This)));
17671767
GC_REFCOUNT(Z_OBJ(EX(This)))++;
17681768
}
17691769

1770-
if (!op_array->run_time_cache && op_array->last_cache_slot) {
1770+
if (!op_array->run_time_cache) {
17711771
if (op_array->function_name) {
17721772
op_array->run_time_cache = zend_arena_calloc(&CG(arena), op_array->last_cache_slot, sizeof(void*));
17731773
} else {

Zend/zend_execute_API.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void shutdown_destructors(TSRMLS_D) /* {{{ */
218218
EG(symbol_table).ht.pDestructor = zend_unclean_zval_ptr_dtor;
219219
}
220220
zend_try {
221-
int symbols;
221+
uint32_t symbols;
222222
do {
223223
symbols = zend_hash_num_elements(&EG(symbol_table).ht);
224224
zend_hash_reverse_apply(&EG(symbol_table).ht, (apply_func_t) zval_call_destructor TSRMLS_CC);
@@ -1542,7 +1542,7 @@ ZEND_API int zend_set_local_var(zend_string *name, zval *value, int force TSRMLS
15421542
}
15431543
/* }}} */
15441544

1545-
ZEND_API int zend_set_local_var_str(const char *name, int len, zval *value, int force TSRMLS_DC) /* {{{ */
1545+
ZEND_API int zend_set_local_var_str(const char *name, size_t len, zval *value, int force TSRMLS_DC) /* {{{ */
15461546
{
15471547
zend_execute_data *execute_data = EG(current_execute_data);
15481548

0 commit comments

Comments
 (0)