mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-18990, bug #81029, bug #47314: SOAP HTTP socket not closing on object destruction Fix leak when path is too long in ZipArchive::extractTo() curl: Remove incorrect string release on error
This commit is contained in:
@@ -1412,7 +1412,6 @@ static inline CURLcode add_simple_field(curl_mime *mime, zend_string *string_key
|
||||
part = curl_mime_addpart(mime);
|
||||
if (part == NULL) {
|
||||
zend_tmp_string_release(tmp_postval);
|
||||
zend_string_release_ex(string_key, 0);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
if ((form_error = curl_mime_name(part, ZSTR_VAL(string_key))) != CURLE_OK
|
||||
|
||||
@@ -506,9 +506,9 @@ try_again:
|
||||
zend_string_equals(orig->host, phpurl->host) &&
|
||||
orig->port == phpurl->port))) {
|
||||
} else {
|
||||
ZVAL_NULL(Z_CLIENT_HTTPSOCKET_P(this_ptr));
|
||||
php_stream_close(stream);
|
||||
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));
|
||||
stream = NULL;
|
||||
use_proxy = 0;
|
||||
@@ -517,9 +517,9 @@ try_again:
|
||||
|
||||
/* Check if keep-alive connection is still opened */
|
||||
if (stream != NULL && php_stream_eof(stream)) {
|
||||
ZVAL_NULL(Z_CLIENT_HTTPSOCKET_P(this_ptr));
|
||||
php_stream_close(stream);
|
||||
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));
|
||||
stream = NULL;
|
||||
use_proxy = 0;
|
||||
@@ -528,9 +528,7 @@ try_again:
|
||||
if (!stream) {
|
||||
stream = http_connect(this_ptr, phpurl, use_ssl, context, &use_proxy);
|
||||
if (stream) {
|
||||
php_stream_auto_cleanup(stream);
|
||||
ZVAL_RES(Z_CLIENT_HTTPSOCKET_P(this_ptr), stream->res);
|
||||
GC_ADDREF(stream->res);
|
||||
php_stream_to_zval(stream, Z_CLIENT_HTTPSOCKET_P(this_ptr));
|
||||
ZVAL_LONG(Z_CLIENT_USE_PROXY_P(this_ptr), use_proxy);
|
||||
} else {
|
||||
php_url_free(phpurl);
|
||||
@@ -686,9 +684,9 @@ try_again:
|
||||
|
||||
if (UNEXPECTED(php_random_bytes_throw(&nonce, sizeof(nonce)) != SUCCESS)) {
|
||||
ZEND_ASSERT(EG(exception));
|
||||
ZVAL_NULL(Z_CLIENT_HTTPSOCKET_P(this_ptr));
|
||||
php_stream_close(stream);
|
||||
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));
|
||||
smart_str_free(&soap_headers_z);
|
||||
smart_str_free(&soap_headers);
|
||||
@@ -904,9 +902,9 @@ try_again:
|
||||
if (request != buf) {
|
||||
zend_string_release_ex(request, 0);
|
||||
}
|
||||
ZVAL_NULL(Z_CLIENT_HTTPSOCKET_P(this_ptr));
|
||||
php_stream_close(stream);
|
||||
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, SOAP_GLOBAL(lang_en));
|
||||
smart_str_free(&soap_headers_z);
|
||||
@@ -929,8 +927,8 @@ try_again:
|
||||
if (request != buf) {
|
||||
zend_string_release_ex(request, 0);
|
||||
}
|
||||
ZVAL_NULL(Z_CLIENT_HTTPSOCKET_P(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, SOAP_GLOBAL(lang_en));
|
||||
smart_str_free(&soap_headers_z);
|
||||
@@ -982,11 +980,11 @@ try_again:
|
||||
if (request != buf) {
|
||||
zend_string_release_ex(request, 0);
|
||||
}
|
||||
ZVAL_NULL(Z_CLIENT_HTTPSOCKET_P(this_ptr));
|
||||
php_stream_close(stream);
|
||||
if (http_headers) {
|
||||
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));
|
||||
if (http_msg) {
|
||||
efree(http_msg);
|
||||
@@ -1117,9 +1115,9 @@ try_again:
|
||||
if (request != buf) {
|
||||
zend_string_release_ex(request, 0);
|
||||
}
|
||||
ZVAL_NULL(Z_CLIENT_HTTPSOCKET_P(this_ptr));
|
||||
php_stream_close(stream);
|
||||
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, SOAP_GLOBAL(lang_en));
|
||||
if (http_msg) {
|
||||
@@ -1134,8 +1132,8 @@ try_again:
|
||||
}
|
||||
|
||||
if (http_close) {
|
||||
ZVAL_NULL(Z_CLIENT_HTTPSOCKET_P(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));
|
||||
stream = NULL;
|
||||
}
|
||||
|
||||
58
ext/soap/tests/bugs/gh18990.phpt
Normal file
58
ext/soap/tests/bugs/gh18990.phpt
Normal file
@@ -0,0 +1,58 @@
|
||||
--TEST--
|
||||
GH-18990 (SOAP HTTP socket not closing on object destruction)
|
||||
--INI--
|
||||
soap.wsdl_cache_enabled=0
|
||||
--EXTENSIONS--
|
||||
soap
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__.'/../../../standard/tests/http/server.inc';
|
||||
http_server_skipif();
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__.'/../../../standard/tests/http/server.inc';
|
||||
|
||||
$wsdl = file_get_contents(__DIR__.'/../server030.wsdl');
|
||||
|
||||
$soap = <<<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getItemsResponse><getItemsReturn SOAP-ENC:arrayType="ns1:Item[10]" xsi:type="ns1:ItemArray"><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text0</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text1</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text2</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text3</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text4</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text5</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text6</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text7</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text8</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text9</text></item></getItemsReturn></ns1:getItemsResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
|
||||
EOF;
|
||||
|
||||
$responses = [
|
||||
"data://text/plain,HTTP/1.1 200 OK\r\n".
|
||||
"Content-Type: text/xml;charset=utf-8\r\n".
|
||||
"Connection: Keep-Alive\r\n".
|
||||
"Content-Length: ".strlen($wsdl)."\r\n".
|
||||
"\r\n".
|
||||
$wsdl,
|
||||
|
||||
"data://text/plain,HTTP/1.1 200 OK\r\n".
|
||||
"Content-Type: text/xml;charset=utf-8\r\n".
|
||||
"Connection: Keep-Alive\r\n".
|
||||
"Content-Length: ".strlen($soap)."\r\n".
|
||||
"\r\n".
|
||||
$soap,
|
||||
];
|
||||
|
||||
['pid' => $pid, 'uri' => $uri] = http_server($responses);
|
||||
|
||||
$options = [
|
||||
'trace' => false,
|
||||
'location' => $uri,
|
||||
];
|
||||
|
||||
$cnt = count(get_resources());
|
||||
|
||||
$client = new SoapClient($uri, $options);
|
||||
|
||||
var_dump(count($client->getItems()));
|
||||
|
||||
http_server_kill($pid);
|
||||
|
||||
unset($client);
|
||||
var_dump(count(get_resources()) - $cnt);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(10)
|
||||
int(0)
|
||||
@@ -211,6 +211,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, const char *file, s
|
||||
return 0;
|
||||
} else if (len > MAXPATHLEN) {
|
||||
php_error_docref(NULL, E_WARNING, "Full extraction path exceed MAXPATHLEN (%i)", MAXPATHLEN);
|
||||
efree(fullpath);
|
||||
efree(file_dirname_fullpath);
|
||||
zend_string_release_ex(file_basename, 0);
|
||||
CWD_STATE_FREE(new_state.cwd);
|
||||
|
||||
Reference in New Issue
Block a user