diff --git a/NEWS b/NEWS index c02edbf7d6c7..5e26189d88ff 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 7070a7205184..d934fda73989 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -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); diff --git a/ext/soap/tests/soapaction_empty_body_header.phpt b/ext/soap/tests/soapaction_empty_body_header.phpt new file mode 100644 index 000000000000..8b2aad16d3cd --- /dev/null +++ b/ext/soap/tests/soapaction_empty_body_header.phpt @@ -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-- + + + secret + + + +--FILE-- +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-- + +auth: secret diff --git a/ext/soap/tests/soapaction_empty_body_header.wsdl b/ext/soap/tests/soapaction_empty_body_header.wsdl new file mode 100644 index 000000000000..1e62ef6ea847 --- /dev/null +++ b/ext/soap/tests/soapaction_empty_body_header.wsdl @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ext/soap/tests/soapaction_empty_body_rpc.phpt b/ext/soap/tests/soapaction_empty_body_rpc.phpt new file mode 100644 index 000000000000..a43611b26551 --- /dev/null +++ b/ext/soap/tests/soapaction_empty_body_rpc.phpt @@ -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-- + + + +--FILE-- +addFunction("getItems"); +$_SERVER["HTTP_SOAPACTION"] = "http://testuri.orgTestServiceAction"; +$server->handle(); +?> +--EXPECT-- + + diff --git a/ext/soap/tests/soapaction_empty_body_rpc_params.phpt b/ext/soap/tests/soapaction_empty_body_rpc_params.phpt new file mode 100644 index 000000000000..738e8f86e76d --- /dev/null +++ b/ext/soap/tests/soapaction_empty_body_rpc_params.phpt @@ -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-- + + + +--FILE-- +addFunction("Add"); +$_SERVER["HTTP_SOAPACTION"] = "Add"; +$server->handle(); +?> +--EXPECT-- + +SOAP-ENV:ClientMissing parameter diff --git a/ext/soap/tests/soapaction_empty_body_rpc_soap12.phpt b/ext/soap/tests/soapaction_empty_body_rpc_soap12.phpt new file mode 100644 index 000000000000..7b2364fedee1 --- /dev/null +++ b/ext/soap/tests/soapaction_empty_body_rpc_soap12.phpt @@ -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-- + + + +--FILE-- + SOAP_1_2]); +$server->addFunction("Add"); +$_SERVER["HTTP_SOAPACTION"] = "Add"; +$server->handle(); +?> +--EXPECT-- + +env:SenderMissing parameter