diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-20 16:24:31 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-20 16:24:31 +0200 |
commit | 6aaab9adf7619c121c19701022aeb8d88f9c3bab (patch) | |
tree | 531c292fdae6364f73f141759788a626888238d8 | |
parent | 50978128f50eb5fa5920aea8a19a5855059a87c7 (diff) | |
parent | 6165c23475d5020cda3794cb684693a7fab9918d (diff) | |
download | php-git-6aaab9adf7619c121c19701022aeb8d88f9c3bab.tar.gz |
Merge branch 'PHP-7.4'
-rw-r--r-- | Zend/zend_execute.c | 2 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 13 | ||||
-rw-r--r-- | Zend/zend_globals.h | 2 | ||||
-rw-r--r-- | Zend/zend_operators.c | 3 | ||||
-rw-r--r-- | Zend/zend_operators.h | 10 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | ext/ffi/ffi.c | 2 | ||||
-rw-r--r-- | ext/soap/soap.c | 3 | ||||
-rw-r--r-- | ext/standard/dns.c | 23 | ||||
-rw-r--r-- | ext/standard/string.c | 2 |
10 files changed, 41 insertions, 20 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index cc2c1a0c20..d25694be18 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -3347,7 +3347,7 @@ ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table) /* {{{ /* clean before putting into the cache, since clean could call dtors, which could use cached hash */ zend_symtable_clean(symbol_table); - *(++EG(symtable_cache_ptr)) = symbol_table; + *(EG(symtable_cache_ptr)++) = symbol_table; } } /* }}} */ diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index a60883fb74..b5460dc51a 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -132,8 +132,8 @@ void init_executor(void) /* {{{ */ original_sigsegv_handler = signal(SIGSEGV, zend_handle_sigsegv); #endif - EG(symtable_cache_ptr) = EG(symtable_cache) - 1; - EG(symtable_cache_limit) = EG(symtable_cache) + SYMTABLE_CACHE_SIZE - 1; + EG(symtable_cache_ptr) = EG(symtable_cache); + EG(symtable_cache_limit) = EG(symtable_cache) + SYMTABLE_CACHE_SIZE; EG(no_extensions) = 0; EG(function_table) = CG(function_table); @@ -398,10 +398,10 @@ void shutdown_executor(void) /* {{{ */ zend_cleanup_internal_classes(); - while (EG(symtable_cache_ptr)>=EG(symtable_cache)) { + while (EG(symtable_cache_ptr) > EG(symtable_cache)) { + EG(symtable_cache_ptr)--; zend_hash_destroy(*EG(symtable_cache_ptr)); FREE_HASHTABLE(*EG(symtable_cache_ptr)); - EG(symtable_cache_ptr)--; } zend_hash_destroy(&EG(included_files)); @@ -1416,9 +1416,8 @@ ZEND_API zend_array *zend_rebuild_symbol_table(void) /* {{{ */ } ZEND_ADD_CALL_FLAG(ex, ZEND_CALL_HAS_SYMBOL_TABLE); - if (EG(symtable_cache_ptr) >= EG(symtable_cache)) { - /*printf("Cache hit! Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/ - symbol_table = ex->symbol_table = *(EG(symtable_cache_ptr)--); + if (EG(symtable_cache_ptr) > EG(symtable_cache)) { + symbol_table = ex->symbol_table = *(--EG(symtable_cache_ptr)); if (!ex->func->op_array.last_var) { return symbol_table; } diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 27ea9d4a8e..281450f3fe 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -136,7 +136,9 @@ struct _zend_executor_globals { /* symbol table cache */ zend_array *symtable_cache[SYMTABLE_CACHE_SIZE]; + /* Pointer to one past the end of the symtable_cache */ zend_array **symtable_cache_limit; + /* Pointer to first unused symtable_cache slot */ zend_array **symtable_cache_ptr; zend_array symbol_table; /* main symbol table */ diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 6b7d5d16ac..17e7434215 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1238,6 +1238,9 @@ ZEND_API int ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* { } /* }}} */ +#ifdef __clang__ +__attribute__((no_sanitize("float-divide-by-zero"))) +#endif ZEND_API int ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* {{{ */ { zval op1_copy, op2_copy; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 5fe7ed6608..59693e00bc 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -225,10 +225,12 @@ zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, const p -= needle_len; do { - if ((p = (const char *)zend_memrchr(haystack, *needle, (p - haystack) + 1)) && ne == p[needle_len-1]) { - if (!memcmp(needle + 1, p + 1, needle_len - 2)) { - return p; - } + p = (const char *)zend_memrchr(haystack, *needle, (p - haystack) + 1); + if (!p) { + return NULL; + } + if (ne == p[needle_len-1] && !memcmp(needle + 1, p + 1, needle_len - 2)) { + return p; } } while (p-- >= haystack); diff --git a/configure.ac b/configure.ac index 95bf4b06fc..b5a0dfc4d0 100644 --- a/configure.ac +++ b/configure.ac @@ -404,6 +404,7 @@ PHP_CHECK_FUNC(gethostbyaddr, nsl) PHP_CHECK_FUNC(yp_get_default_domain, nsl) PHP_CHECK_FUNC(dlopen, dl) +PHP_CHECK_FUNC(dlsym, dl) if test "$ac_cv_func_dlopen" = "yes"; then AC_DEFINE(HAVE_LIBDL, 1, [ ]) fi diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 61ccdbd27c..a1c2a845fe 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -1615,7 +1615,7 @@ static zend_object* zend_ffi_add(zend_ffi_cdata *base_cdata, zend_ffi_type *base } cdata->ptr = &cdata->ptr_holder; cdata->ptr_holder = ptr + - offset * ZEND_FFI_TYPE(ptr_type)->size; + (ptrdiff_t) (offset * ZEND_FFI_TYPE(ptr_type)->size); cdata->flags = base_cdata->flags & ZEND_FFI_FLAG_CONST; return &cdata->std; } diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 9eebe19096..f324f99310 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -4068,7 +4068,8 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function int hdr_use = SOAP_LITERAL; zval *hdr_ret = &h->retval; char *hdr_ns = h->hdr?h->hdr->ns:NULL; - char *hdr_name = Z_STRVAL(h->function_name); + char *hdr_name = Z_TYPE(h->function_name) == IS_STRING + ? Z_STRVAL(h->function_name) : NULL; HashTable *ht = NULL; if (Z_TYPE(h->retval) == IS_OBJECT && diff --git a/ext/standard/dns.c b/ext/standard/dns.c index 6e856842f9..e5ce3ceeb5 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -248,14 +248,21 @@ PHP_FUNCTION(gethostbynamel) } hp = php_network_gethostbyname(hostname); - if (hp == NULL || hp->h_addr_list == NULL) { + if (!hp) { RETURN_FALSE; } array_init(return_value); - for (i = 0 ; hp->h_addr_list[i] != 0 ; i++) { - in = *(struct in_addr *) hp->h_addr_list[i]; + for (i = 0; hp->h_addr_list[i] != 0 ; i++) { + /* On macos h_addr_list entries may be misaligned. */ + struct in_addr *h_addr_entry; /* Don't call this h_addr, it's a macro! */ + memcpy(&h_addr_entry, &hp->h_addr_list[i], sizeof(struct in_addr *)); + if (!h_addr_entry) { + return; + } + + in = *h_addr_entry; add_next_index_string(return_value, inet_ntoa(in)); } } @@ -265,16 +272,22 @@ PHP_FUNCTION(gethostbynamel) static zend_string *php_gethostbyname(char *name) { struct hostent *hp; + struct in_addr *h_addr_0; /* Don't call this h_addr, it's a macro! */ struct in_addr in; char *address; hp = php_network_gethostbyname(name); + if (!hp) { + return zend_string_init(name, strlen(name), 0); + } - if (!hp || !*(hp->h_addr_list)) { + /* On macos h_addr_list entries may be misaligned. */ + memcpy(&h_addr_0, &hp->h_addr_list[0], sizeof(struct in_addr *)); + if (!h_addr_0) { return zend_string_init(name, strlen(name), 0); } - memcpy(&in.s_addr, *(hp->h_addr_list), sizeof(in.s_addr)); + memcpy(&in.s_addr, h_addr_0, sizeof(in.s_addr)); address = inet_ntoa(in); return zend_string_init(address, strlen(address), 0); diff --git a/ext/standard/string.c b/ext/standard/string.c index 5c56bb4f62..bf2891c690 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2057,7 +2057,7 @@ PHP_FUNCTION(strripos) php_error_docref(NULL, E_WARNING, "Offset is greater than the length of haystack string"); RETURN_FALSE; } - e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack) + (size_t)offset; + e = ZSTR_VAL(haystack) + (ZSTR_LEN(haystack) + (size_t)offset); } /* Borrow that ord_needle buffer to avoid repeatedly tolower()ing needle */ lowered = tolower(*ZSTR_VAL(needle)); |