]> granicus.if.org Git - php/commitdiff
Fix bug #77410
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 4 Jan 2019 11:40:28 +0000 (12:40 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 4 Jan 2019 11:40:28 +0000 (12:40 +0100)
NEWS
ext/soap/php_encoding.c
ext/soap/tests/bug77410.phpt [new file with mode: 0644]
ext/soap/tests/bug77410.wsdl [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index ddfb0c9b419d4a19ac45a53670e5418f2637937b..eec10f3ef15eb5344682e80071128e3522f1a752 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -35,6 +35,10 @@ PHP                                                                        NEWS
   . Fixed bug #77273 (array_walk_recursive corrupts value types leading to PDO
     failure). (Nikita)
 
+- SOAP:
+  . Fixed bug #77410 (Segmentation Fault when executing method with an empty
+    parameter). (Nikita)
+
 - Sockets:
   . Fixed bug #76839 (socket_recvfrom may return an invalid 'from' address
     on MacOS). (Michael Meyer)
index cd7ea0664949130805aad4f950e0d6fe2c64b908..87e13161c7a43524bff9d295c87594b0929b2116 100644 (file)
@@ -1856,9 +1856,9 @@ static xmlNodePtr to_xml_object(encodeTypePtr type, zval *data, int style, xmlNo
                            sdlType->encode->details.sdl_type->kind != XSD_TYPEKIND_LIST &&
                            sdlType->encode->details.sdl_type->kind != XSD_TYPEKIND_UNION) {
 
-                               if (prop) {GC_PROTECT_RECURSION(prop);}
+                               if (prop) { GC_TRY_PROTECT_RECURSION(prop); }
                                xmlParam = master_to_xml(sdlType->encode, data, style, parent);
-                               if (prop) {GC_UNPROTECT_RECURSION(prop);}
+                               if (prop) { GC_TRY_UNPROTECT_RECURSION(prop); }
                        } else {
                                zval rv;
                                zval *tmp = get_zval_property(data, "_", &rv);
diff --git a/ext/soap/tests/bug77410.phpt b/ext/soap/tests/bug77410.phpt
new file mode 100644 (file)
index 0000000..2b74102
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+Bug #77410: Segmentation Fault when executing method with an empty parameter
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$client = new class(__DIR__ . '/bug77410.wsdl', [
+    'cache_wsdl' => WSDL_CACHE_NONE,
+    'trace' => 1,
+]) extends SoapClient {
+    public function __doRequest($request, $location, $action, $version, $one_way = 0) {
+        echo $request, "\n";
+        return ''; 
+    }
+};
+
+$client->MyMethod([
+    'parameter' => [],
+]);
+
+?>
+--EXPECT--
+<?xml version="1.0" encoding="UTF-8"?>
+<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:test"><SOAP-ENV:Body><ns1:MyMethodRequest><parameter/></ns1:MyMethodRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
diff --git a/ext/soap/tests/bug77410.wsdl b/ext/soap/tests/bug77410.wsdl
new file mode 100644 (file)
index 0000000..fb97648
--- /dev/null
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<definitions targetNamespace="urn:test"
+   xmlns="http://schemas.xmlsoap.org/wsdl/"
+   xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+   xmlns:test="urn:test"
+   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+   <portType name="TestPortType">
+      <operation name="MyMethod">
+         <input message="test:MyMethodRequestMessage" />
+         <output message="test:MyMethodResponseMessage" />
+      </operation>
+   </portType>
+
+   <binding name="TestBinding" type="test:TestPortType">
+      <operation name="MyMethod">
+         <input><soap:body use="literal" /></input>
+         <output><soap:body use="literal" /></output>
+      </operation>
+   </binding>
+
+   <message name="MyMethodRequestMessage">
+      <part name="parameters" element="test:MyMethodRequest" />
+   </message>
+
+   <message name="MyMethodResponseMessage">
+      <part name="parameters" element="test:MyMethodResponse" />
+   </message>
+
+   <types>
+      <schema targetNamespace="urn:test" xmlns="http://www.w3.org/2001/XMLSchema">
+
+         <element name="MyMethodRequest">
+            <complexType>
+               <sequence>
+                  <element name="parameter" type="test:MyMethodRequestObject" />
+               </sequence>
+            </complexType>
+         </element>
+
+         <element name="MyMethodResponse" />
+
+         <complexType name="MyMethodRequestObject">
+            <complexContent>
+               <extension base="test:DynamicData" />
+            </complexContent>
+         </complexType>
+
+         <complexType name="DynamicData" />
+
+      </schema>
+   </types>
+
+   <service name="TestService">
+      <port binding="test:TestBinding" name="TestPort">
+         <soap:address location="http://localhost:8080/test-service" />
+      </port>
+   </service>
+
+</definitions>