Skip to content

Commit 9e79cb2

Browse files
committed
Merge branch 'master' into jit-dynasm
* master: Fixed bug #77697 (Crash on Big_Endian platform) Add tests to XMLReader Fix failing test Clean build system Remove HAVE_STRFTIME Fix weakref object handlers for master ext/session: remove the redundant convert_to_long Fixed bug #77742 updated NEWS Fixed bug #77738 (Nullptr deref in zend_compile_expr)
2 parents 0a1d718 + 9f9b257 commit 9e79cb2

File tree

24 files changed

+167
-66
lines changed

24 files changed

+167
-66
lines changed

Zend/Zend.m4

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ unix.h \
2222
cpuid.h \
2323
dlfcn.h)
2424
25-
AC_TYPE_SIZE_T
26-
2725
AC_DEFUN([LIBZEND_DLSYM_CHECK],[
2826
dnl
2927
dnl Ugly hack to check if dlsym() requires a leading underscore in symbol name.
@@ -40,8 +38,7 @@ _LT_AC_TRY_DLOPEN_SELF([
4038
])
4139
4240
dnl Checks for library functions.
43-
AC_FUNC_ALLOCA
44-
AC_CHECK_FUNCS(strdup getpid kill strtod strtol finite fpclass sigsetjmp)
41+
AC_CHECK_FUNCS(getpid kill strtod finite fpclass sigsetjmp)
4542
4643
AC_CHECK_DECLS([isfinite, isnan, isinf], [], [], [[#include <math.h>]])
4744

Zend/tests/bug77738.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #77738 (Nullptr deref in zend_compile_expr)
3+
--FILE--
4+
<?php
5+
__COMPILER_HALT_OFFSET__;
6+
; // <- important
7+
--EXPECTF--
8+
Fatal error: Uncaught Error: Undefined constant '__COMPILER_HALT_OFFSET__' in %s:%d
9+
Stack trace:
10+
#0 {main}
11+
thrown in %s on line %d

Zend/zend_compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7583,11 +7583,11 @@ void zend_compile_const(znode *result, zend_ast *ast) /* {{{ */
75837583
if (zend_string_equals_literal(resolved_name, "__COMPILER_HALT_OFFSET__") || (name_ast->attr != ZEND_NAME_RELATIVE && zend_string_equals_literal(orig_name, "__COMPILER_HALT_OFFSET__"))) {
75847584
zend_ast *last = CG(ast);
75857585

7586-
while (last->kind == ZEND_AST_STMT_LIST) {
7586+
while (last && last->kind == ZEND_AST_STMT_LIST) {
75877587
zend_ast_list *list = zend_ast_get_list(last);
75887588
last = list->child[list->children-1];
75897589
}
7590-
if (last->kind == ZEND_AST_HALT_COMPILER) {
7590+
if (last && last->kind == ZEND_AST_HALT_COMPILER) {
75917591
result->op_type = IS_CONST;
75927592
ZVAL_LONG(&result->u.constant, Z_LVAL_P(zend_ast_get_zval(last->child[0])));
75937593
zend_string_release_ex(resolved_name, 0);

Zend/zend_weakrefs.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,33 +112,33 @@ static void zend_weakref_free(zend_object *zo) {
112112
#define zend_weakref_unsupported(thing) \
113113
zend_throw_error(NULL, "WeakReference objects do not support " thing);
114114

115-
static zval* zend_weakref_no_write(zval *object, zval *member, zval *value, void **rtc) {
115+
static zval* zend_weakref_no_write(zend_object *object, zend_string *member, zval *value, void **rtc) {
116116
zend_weakref_unsupported("properties");
117117

118118
return &EG(uninitialized_zval);
119119
}
120120

121-
static zval* zend_weakref_no_read(zval *object, zval *member, int type, void **rtc, zval *rv) {
121+
static zval* zend_weakref_no_read(zend_object *object, zend_string *member, int type, void **rtc, zval *rv) {
122122
if (!EG(exception)) {
123123
zend_weakref_unsupported("properties");
124124
}
125125

126126
return &EG(uninitialized_zval);
127127
}
128128

129-
static zval *zend_weakref_no_read_ptr(zval *object, zval *member, int type, void **rtc) {
129+
static zval *zend_weakref_no_read_ptr(zend_object *object, zend_string *member, int type, void **rtc) {
130130
zend_weakref_unsupported("property references");
131131
return NULL;
132132
}
133133

134-
static int zend_weakref_no_isset(zval *object, zval *member, int hse, void **rtc) {
134+
static int zend_weakref_no_isset(zend_object *object, zend_string *member, int hse, void **rtc) {
135135
if (hse != 2) {
136136
zend_weakref_unsupported("properties");
137137
}
138138
return 0;
139139
}
140140

141-
static void zend_weakref_no_unset(zval *object, zval *member, void **rtc) {
141+
static void zend_weakref_no_unset(zend_object *object, zend_string *member, void **rtc) {
142142
zend_weakref_unsupported("properties");
143143
}
144144

configure.ac

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,6 @@ memmove \
632632
mkstemp \
633633
mmap \
634634
nl_langinfo \
635-
perror \
636635
poll \
637636
ptsname \
638637
putenv \
@@ -658,10 +657,8 @@ strcasecmp \
658657
strcoll \
659658
strdup \
660659
strerror \
661-
strftime \
662660
strnlen \
663661
strptime \
664-
strstr \
665662
strtok_r \
666663
symlink \
667664
tempnam \

ext/bcmath/libbcmath/src/num2long.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,19 @@ bc_num2long (num)
5353
/* Extract the int value, ignore the fraction. */
5454
val = 0;
5555
nptr = num->n_value;
56-
for (index=num->n_len; (index>0) && (val<=(LONG_MAX/BASE)); index--)
57-
val = val*BASE + *nptr++;
56+
for (index = num->n_len; index > 0; index--) {
57+
char n = *nptr++;
5858

59-
/* Check for overflow. If overflow, return zero. */
60-
if (index>0) val = 0;
61-
if (val < 0) val = 0;
59+
if (val > LONG_MAX/BASE) {
60+
return 0;
61+
}
62+
val *= BASE;
63+
64+
if (val > LONG_MAX - n) {
65+
return 0;
66+
}
67+
val += n;
68+
}
6269

6370
/* Return the value. */
6471
if (num->n_sign == PLUS)

ext/date/php_date.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,8 @@ static const zend_function_entry date_functions[] = {
409409
PHP_FE(mktime, arginfo_mktime)
410410
PHP_FE(gmmktime, arginfo_gmmktime)
411411
PHP_FE(checkdate, arginfo_checkdate)
412-
413-
#ifdef HAVE_STRFTIME
414412
PHP_FE(strftime, arginfo_strftime)
415413
PHP_FE(gmstrftime, arginfo_gmstrftime)
416-
#endif
417-
418414
PHP_FE(time, arginfo_time)
419415
PHP_FE(localtime, arginfo_localtime)
420416
PHP_FE(getdate, arginfo_getdate)
@@ -1633,7 +1629,6 @@ PHP_FUNCTION(checkdate)
16331629
}
16341630
/* }}} */
16351631

1636-
#ifdef HAVE_STRFTIME
16371632
/* {{{ php_strftime - (gm)strftime helper */
16381633
PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
16391634
{
@@ -1745,7 +1740,6 @@ PHP_FUNCTION(gmstrftime)
17451740
php_strftime(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
17461741
}
17471742
/* }}} */
1748-
#endif
17491743

17501744
/* {{{ proto int time(void)
17511745
Return current UNIX timestamp */

ext/date/php_date.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,8 @@ PHP_FUNCTION(mktime);
3737
PHP_FUNCTION(gmmktime);
3838

3939
PHP_FUNCTION(checkdate);
40-
41-
#ifdef HAVE_STRFTIME
4240
PHP_FUNCTION(strftime);
4341
PHP_FUNCTION(gmstrftime);
44-
#endif
45-
4642
PHP_FUNCTION(time);
4743
PHP_FUNCTION(localtime);
4844
PHP_FUNCTION(getdate);
@@ -207,10 +203,10 @@ ZEND_END_MODULE_GLOBALS(date)
207203
PHPAPI zend_long php_parse_date(char *string, zend_long *now);
208204
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt);
209205
PHPAPI int php_idate(char format, time_t ts, int localtime);
210-
#if HAVE_STRFTIME
206+
211207
#define _php_strftime php_strftime
208+
212209
PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm);
213-
#endif
214210
PHPAPI zend_string *php_format_date(char *format, size_t format_len, time_t ts, int localtime);
215211

216212
/* Mechanism to set new TZ database */

ext/date/tests/009.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ strftime() and gmstrftime() tests
33
--SKIPIF--
44
<?php
55
if (substr(PHP_OS, 0, 3) == 'WIN') die('skip posix only test.');
6-
if (!function_exists('strftime')) die("skip, strftime not available");
76
?>
87
--FILE--
98
<?php

ext/date/tests/009_win32.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ strftime() and gmstrftime() tests
33
--SKIPIF--
44
<?php
55
if (substr(PHP_OS, 0, 3) != 'WIN') die('skip only windows test.');
6-
if (!function_exists('strftime')) die("skip, strftime not available");
76
if (false === setlocale(LC_TIME, "en-us")) die("skip, couldn't set the locale to en-us");
87
?>
98
--FILE--

0 commit comments

Comments
 (0)