Commit 19fcd2e80f2 for php
commit 19fcd2e80f27c0c2a1c5732ad06ced7c41262611
Author: Jorg Sowa <jorg.sowa@gmail.com>
Date: Tue Nov 24 11:13:09 2026 +0100
ext/soap: Fix NULL dereference on empty Body with matching SOAPAction (GH-25661)
Since 63e0b9ccbfe the function can be resolved from the SOAPAction
header when the Body has no function element, leaving func NULL.
Closes GH-25661
diff --git a/NEWS b/NEWS
index dfec4033c9a..af9564888d1 100644
--- a/NEWS
+++ b/NEWS
@@ -167,6 +167,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 7070a720518..d934fda7398 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 00000000000..8b2aad16d3c
--- /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--
+<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>
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 00000000000..1e62ef6ea84
--- /dev/null
+++ b/ext/soap/tests/soapaction_empty_body_header.wsdl
@@ -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>
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 00000000000..a43611b2655
--- /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--
+<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>
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 00000000000..738e8f86e76
--- /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--
+<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>
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 00000000000..7b2364fedee
--- /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--
+<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>