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 /ext | |
parent | 50978128f50eb5fa5920aea8a19a5855059a87c7 (diff) | |
parent | 6165c23475d5020cda3794cb684693a7fab9918d (diff) | |
download | php-git-6aaab9adf7619c121c19701022aeb8d88f9c3bab.tar.gz |
Merge branch 'PHP-7.4'
Diffstat (limited to 'ext')
-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 |
4 files changed, 22 insertions, 8 deletions
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)); |