Skip to content
Closed
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 @@ -161,6 +161,8 @@ PHP NEWS
- SOAP:
. Fixed bug GH-25267 (NULL dereference in to_xml_any() with integer key).
(lazerg)
. Fixed NULL dereference in SoapServer::handle() with an empty Body and a
SOAPAction matching an RPC operation. (Jorg Sowa)

- Sockets:
. Fixed bug GH-25530 (socket_last_error() without a socket returns an error
Expand Down
13 changes: 8 additions & 5 deletions ext/soap/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3488,13 +3488,16 @@ static sdlFunctionPtr deserialize_function_call(sdlPtr sdl, xmlDocPtr request, c
}
}

if (function && function->binding && function->binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes;
if (fnb->style == SOAP_RPC) {
/* func is NULL when the function was resolved via SOAPAction and the Body is empty */
if (func) {
if (function && function->binding && function->binding->bindingType == BINDING_SOAP) {
sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes;
if (fnb->style == SOAP_RPC) {
func = func->children;
}
} else {
func = func->children;
}
} else {
func = func->children;
}
deserialize_parameters(func, function, num_params, parameters);

Expand Down
35 changes: 35 additions & 0 deletions ext/soap/tests/soapaction_empty_body_header.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
--TEST--
SoapServer::handle() with Header, empty Body and SOAPAction matching an RPC operation
--EXTENSIONS--
soap
--INI--
soap.wsdl_cache_enabled=0
--POST--
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org">
<SOAP-ENV:Header>
<ns1:Auth SOAP-ENV:mustUnderstand="1">secret</ns1:Auth>
</SOAP-ENV:Header>
<SOAP-ENV:Body/>
</SOAP-ENV:Envelope>
--FILE--
<?php
class Service {
private string $auth = 'none';

public function Auth($value) {
$this->auth = $value;
}

public function test() {
return "auth: " . $this->auth;
}
}

$server = new SoapServer(__DIR__.'/soapaction_empty_body_header.wsdl');
$server->setObject(new Service());
$_SERVER["HTTP_SOAPACTION"] = "Test";
$server->handle();
?>
--EXPECT--
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org"><SOAP-ENV:Body><ns1:testResponse><result>auth: secret</result></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
44 changes: 44 additions & 0 deletions ext/soap/tests/soapaction_empty_body_header.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" ?>
<definitions
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://testuri.org"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://testuri.org">

<message name="AuthHeader">
<part name="Auth" type="xsd:string" />
</message>
<message name="TestRequest">
</message>
<message name="TestResponse">
<part name="result" type="xsd:string" />
</message>

<portType name="TestServicePortType">
<operation name="test">
<input message="tns:TestRequest" />
<output message="tns:TestResponse" />
</operation>
</portType>

<binding name="TestServiceBinding" type="tns:TestServicePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="test">
<soap:operation soapAction="Test" style="rpc" />
<input>
<soap:body namespace="http://testuri.org" use="literal" />
<soap:header namespace="http://testuri.org" message="tns:AuthHeader" part="Auth" use="literal" />
</input>
<output>
<soap:body namespace="http://testuri.org" use="literal" />
</output>
</operation>
</binding>

<service name="TestService">
<port name="TestServicePort" binding="tns:TestServiceBinding">
<soap:address location="http://localhost/" />
</port>
</service>
</definitions>
24 changes: 24 additions & 0 deletions ext/soap/tests/soapaction_empty_body_rpc.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
SoapServer::handle() with empty Body and SOAPAction matching an RPC operation
--EXTENSIONS--
soap
--INI--
soap.wsdl_cache_enabled=0
--POST--
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body/>
</SOAP-ENV:Envelope>
--FILE--
<?php
function getItems() {
return [];
}

$server = new SoapServer(__DIR__.'/server030.wsdl');
$server->addFunction("getItems");
$_SERVER["HTTP_SOAPACTION"] = "http://testuri.orgTestServiceAction";
$server->handle();
?>
--EXPECT--
<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getItemsResponse><getItemsReturn SOAP-ENC:arrayType="ns1:Item[0]" xsi:type="ns1:ItemArray"/></ns1:getItemsResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
24 changes: 24 additions & 0 deletions ext/soap/tests/soapaction_empty_body_rpc_params.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
SoapServer::handle() with empty Body and SOAPAction matching an RPC operation with parameters
--EXTENSIONS--
soap
--INI--
soap.wsdl_cache_enabled=0
--POST--
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body/>
</SOAP-ENV:Envelope>
--FILE--
<?php
function Add($x, $y) {
return $x + $y;
}

$server = new SoapServer(__DIR__.'/test.wsdl');
$server->addFunction("Add");
$_SERVER["HTTP_SOAPACTION"] = "Add";
$server->handle();
?>
--EXPECT--
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Missing parameter</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
24 changes: 24 additions & 0 deletions ext/soap/tests/soapaction_empty_body_rpc_soap12.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
SoapServer::handle() with empty SOAP 1.2 Body and SOAPAction matching an RPC operation with parameters
--EXTENSIONS--
soap
--INI--
soap.wsdl_cache_enabled=0
--POST--
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Body/>
</env:Envelope>
--FILE--
<?php
function Add($x, $y) {
return $x + $y;
}

$server = new SoapServer(__DIR__.'/test.wsdl', ['soap_version' => SOAP_1_2]);
$server->addFunction("Add");
$_SERVER["HTTP_SOAPACTION"] = "Add";
$server->handle();
?>
--EXPECT--
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><env:Fault><env:Code><env:Value>env:Sender</env:Value></env:Code><env:Reason><env:Text xml:lang="en">Missing parameter</env:Text></env:Reason></env:Fault></env:Body></env:Envelope>
Loading