Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ PHP NEWS
. Fixed bug #70951 (Segmentation fault on invalid WSDL cache). (nielsdos)
. Implement request #55503 (Extend __getTypes to support enumerations).
(nielsdos, datibbaw)
. Implement request #61105 (Support Soap 1.2 SoapFault Reason Text lang
attribute). (nielsdos)

- Sockets:
. Added IPPROTO_ICMP/IPPROTO_ICMPV6 to create raw socket for ICMP usage.
Expand Down
5 changes: 5 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ PHP 8.5 UPGRADE NOTES

- SOAP:
. Enumeration cases are now dumped in __getTypes().
. Implemented request #61105:
support for Soap 1.2 Reason Text xml:lang attribute.
The signature of SoapFault::__construct() and SoapServer::fault() therefore
now have an optional $lang parameter.
This support solves compatibility with .NET SOAP clients.

- XSL:
. The $namespace argument of XSLTProcessor::getParameter(),
Expand Down
3 changes: 3 additions & 0 deletions ext/curl/curl_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ void _php_curl_multi_cleanup_list(void *data);
void _php_curl_verify_handlers(php_curl *ch, bool reporterror);
void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source);

/* Consumes `zv` */
zend_long php_curl_get_long(zval *zv);

static inline php_curl *curl_from_obj(zend_object *obj) {
return (php_curl *)((char *)(obj) - XtOffsetOf(php_curl, std));
}
Expand Down
22 changes: 17 additions & 5 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
if (!Z_ISUNDEF(retval)) {
_php_curl_verify_handlers(ch, /* reporterror */ true);
/* TODO Check callback returns an int or something castable to int */
length = zval_get_long(&retval);
length = php_curl_get_long(&retval);
}

zval_ptr_dtor(&argv[0]);
Expand Down Expand Up @@ -657,7 +657,7 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
if (!Z_ISUNDEF(retval)) {
_php_curl_verify_handlers(ch, /* reporterror */ true);
/* TODO Check callback returns an int or something castable to int */
rval = zval_get_long(&retval);
rval = php_curl_get_long(&retval);
}
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
Expand Down Expand Up @@ -694,7 +694,7 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
if (!Z_ISUNDEF(retval)) {
_php_curl_verify_handlers(ch, /* reporterror */ true);
/* TODO Check callback returns an int or something castable to int */
if (0 != zval_get_long(&retval)) {
if (0 != php_curl_get_long(&retval)) {
rval = 1;
}
}
Expand Down Expand Up @@ -732,7 +732,7 @@ static size_t curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow,
if (!Z_ISUNDEF(retval)) {
_php_curl_verify_handlers(ch, /* reporterror */ true);
/* TODO Check callback returns an int or something castable to int */
if (0 != zval_get_long(&retval)) {
if (0 != php_curl_get_long(&retval)) {
rval = 1;
}
}
Expand Down Expand Up @@ -831,6 +831,7 @@ static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key,
}
} else {
zend_throw_error(NULL, "The CURLOPT_SSH_HOSTKEYFUNCTION callback must return either CURLKHMATCH_OK or CURLKHMATCH_MISMATCH");
zval_ptr_dtor(&retval);
}
}

Expand Down Expand Up @@ -925,7 +926,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
if (!Z_ISUNDEF(retval)) {
// TODO: Check for valid int type for return value
_php_curl_verify_handlers(ch, /* reporterror */ true);
length = zval_get_long(&retval);
length = php_curl_get_long(&retval);
}
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
Expand Down Expand Up @@ -1343,6 +1344,17 @@ void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source)
(*source->clone)++;
}

zend_long php_curl_get_long(zval *zv)
{
if (EXPECTED(Z_TYPE_P(zv) == IS_LONG)) {
return Z_LVAL_P(zv);
} else {
zend_long ret = zval_get_long(zv);
zval_ptr_dtor(zv);
return ret;
}
}

static size_t read_cb(char *buffer, size_t size, size_t nitems, void *arg) /* {{{ */
{
struct mime_data_cb_arg *cb_arg = (struct mime_data_cb_arg *) arg;
Expand Down
2 changes: 1 addition & 1 deletion ext/curl/multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ static int _php_server_push_callback(CURL *parent_ch, CURL *easy, size_t num_hea
zval_ptr_dtor_nogc(&headers);

if (!Z_ISUNDEF(retval)) {
if (CURL_PUSH_DENY != zval_get_long(&retval)) {
if (CURL_PUSH_DENY != php_curl_get_long(&retval)) {
rval = CURL_PUSH_OK;
zend_llist_add_element(&mh->easyh, &pz_ch);
} else {
Expand Down
27 changes: 27 additions & 0 deletions ext/curl/tests/refcounted_return_must_not_leak.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--TEST--
Returning refcounted value from callback must not leak
--EXTENSIONS--
curl
--FILE--
<?php
include 'server.inc';
$host = curl_cli_server_start();

$url = "{$host}/get.inc";
$ch = curl_init($url);

function return_non_interned_string() {
return str_repeat('x', random_int(5, 5));
}

curl_setopt($ch, CURLOPT_NOPROGRESS, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'return_non_interned_string');
curl_setopt($ch, CURLOPT_XFERINFOFUNCTION, 'return_non_interned_string');
curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'return_non_interned_string');
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'return_non_interned_string');
echo curl_exec($ch), PHP_EOL;
echo "ok";
?>
--EXPECT--
ok
24 changes: 12 additions & 12 deletions ext/soap/php_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ int make_http_soap_request(zval *this_ptr,
if (request != buf) {
zend_string_release_ex(request, 0);
}
add_soap_fault(this_ptr, "HTTP", "Unable to parse URL", NULL, NULL);
add_soap_fault(this_ptr, "HTTP", "Unable to parse URL", NULL, NULL, SOAP_GLOBAL(lang_en));
smart_str_free(&soap_headers_z);
efree(http_msg);
return FALSE;
Expand All @@ -469,7 +469,7 @@ int make_http_soap_request(zval *this_ptr,
if (request != buf) {
zend_string_release_ex(request, 0);
}
add_soap_fault(this_ptr, "HTTP", "Unknown protocol. Only http and https are allowed.", NULL, NULL);
add_soap_fault(this_ptr, "HTTP", "Unknown protocol. Only http and https are allowed.", NULL, NULL, SOAP_GLOBAL(lang_en));
smart_str_free(&soap_headers_z);
efree(http_msg);
return FALSE;
Expand All @@ -482,7 +482,7 @@ int make_http_soap_request(zval *this_ptr,
if (request != buf) {
zend_string_release_ex(request, 0);
}
add_soap_fault(this_ptr, "HTTP", "SSL support is not available in this build", NULL, NULL);
add_soap_fault(this_ptr, "HTTP", "SSL support is not available in this build", NULL, NULL, SOAP_GLOBAL(lang_en));
PG(allow_url_fopen) = old_allow_url_fopen;
smart_str_free(&soap_headers_z);
efree(http_msg);
Expand Down Expand Up @@ -537,7 +537,7 @@ int make_http_soap_request(zval *this_ptr,
if (request != buf) {
zend_string_release_ex(request, 0);
}
add_soap_fault(this_ptr, "HTTP", "Could not connect to host", NULL, NULL);
add_soap_fault(this_ptr, "HTTP", "Could not connect to host", NULL, NULL, SOAP_GLOBAL(lang_en));
PG(allow_url_fopen) = old_allow_url_fopen;
smart_str_free(&soap_headers_z);
efree(http_msg);
Expand Down Expand Up @@ -908,14 +908,14 @@ int make_http_soap_request(zval *this_ptr,
convert_to_null(Z_CLIENT_HTTPURL_P(this_ptr));
convert_to_null(Z_CLIENT_HTTPSOCKET_P(this_ptr));
convert_to_null(Z_CLIENT_USE_PROXY_P(this_ptr));
add_soap_fault(this_ptr, "HTTP", "Failed Sending HTTP SOAP request", NULL, NULL);
add_soap_fault(this_ptr, "HTTP", "Failed Sending HTTP SOAP request", NULL, NULL, SOAP_GLOBAL(lang_en));
smart_str_free(&soap_headers_z);
efree(http_msg);
return FALSE;
}
smart_str_free(&soap_headers);
} else {
add_soap_fault(this_ptr, "HTTP", "Failed to create stream??", NULL, NULL);
add_soap_fault(this_ptr, "HTTP", "Failed to create stream??", NULL, NULL, SOAP_GLOBAL(lang_en));
smart_str_free(&soap_headers_z);
efree(http_msg);
return FALSE;
Expand All @@ -932,7 +932,7 @@ int make_http_soap_request(zval *this_ptr,
php_stream_close(stream);
convert_to_null(Z_CLIENT_HTTPSOCKET_P(this_ptr));
convert_to_null(Z_CLIENT_USE_PROXY_P(this_ptr));
add_soap_fault(this_ptr, "HTTP", "Error Fetching http headers", NULL, NULL);
add_soap_fault(this_ptr, "HTTP", "Error Fetching http headers", NULL, NULL, SOAP_GLOBAL(lang_en));
smart_str_free(&soap_headers_z);
efree(http_msg);
return FALSE;
Expand Down Expand Up @@ -1121,7 +1121,7 @@ int make_http_soap_request(zval *this_ptr,
zend_string_release_ex(http_headers, 0);
convert_to_null(Z_CLIENT_HTTPSOCKET_P(this_ptr));
convert_to_null(Z_CLIENT_USE_PROXY_P(this_ptr));
add_soap_fault(this_ptr, "HTTP", "Error Fetching http body, No Content-Length, connection closed or chunked data", NULL, NULL);
add_soap_fault(this_ptr, "HTTP", "Error Fetching http body, No Content-Length, connection closed or chunked data", NULL, NULL, SOAP_GLOBAL(lang_en));
if (http_msg) {
efree(http_msg);
}
Expand Down Expand Up @@ -1180,7 +1180,7 @@ int make_http_soap_request(zval *this_ptr,
phpurl = new_url;

if (--redirect_max < 1) {
add_soap_fault(this_ptr, "HTTP", "Redirection limit reached, aborting", NULL, NULL);
add_soap_fault(this_ptr, "HTTP", "Redirection limit reached, aborting", NULL, NULL, SOAP_GLOBAL(lang_en));
smart_str_free(&soap_headers_z);
efree(http_msg);
return FALSE;
Expand Down Expand Up @@ -1318,7 +1318,7 @@ int make_http_soap_request(zval *this_ptr,
if (http_msg) {
efree(http_msg);
}
add_soap_fault(this_ptr, "HTTP", "Unknown Content-Encoding", NULL, NULL);
add_soap_fault(this_ptr, "HTTP", "Unknown Content-Encoding", NULL, NULL, SOAP_GLOBAL(lang_en));
return FALSE;
}
if (call_user_function(CG(function_table), (zval*)NULL, &func, &retval, 1, params) == SUCCESS &&
Expand All @@ -1334,7 +1334,7 @@ int make_http_soap_request(zval *this_ptr,
efree(content_encoding);
zend_string_release_ex(http_headers, 0);
zend_string_release_ex(http_body, 0);
add_soap_fault(this_ptr, "HTTP", "Can't uncompress compressed response", NULL, NULL);
add_soap_fault(this_ptr, "HTTP", "Can't uncompress compressed response", NULL, NULL, SOAP_GLOBAL(lang_en));
if (http_msg) {
efree(http_msg);
}
Expand Down Expand Up @@ -1368,7 +1368,7 @@ int make_http_soap_request(zval *this_ptr,
if (error) {
zval_ptr_dtor(return_value);
ZVAL_UNDEF(return_value);
add_soap_fault(this_ptr, "HTTP", http_msg, NULL, NULL);
add_soap_fault(this_ptr, "HTTP", http_msg, NULL, NULL, SOAP_GLOBAL(lang_en));
efree(http_msg);
return FALSE;
}
Expand Down
Loading