]> granicus.if.org Git - php/commitdiff
Fixed bug #32941 (Sending structured SOAP fault kills a php)
authorDmitry Stogov <dmitry@php.net>
Wed, 1 Jun 2005 14:42:50 +0000 (14:42 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 1 Jun 2005 14:42:50 +0000 (14:42 +0000)
NEWS
ext/soap/php_encoding.c
ext/soap/php_schema.c
ext/soap/php_sdl.c
ext/soap/tests/bugs/bug32941.phpt [new file with mode: 0755]
ext/soap/tests/bugs/bug32941.wsdl [new file with mode: 0755]

diff --git a/NEWS b/NEWS
index eb3438006c00b21ea6a05f216a42013bff069f92..781d72c42afd8f00395564266bdb967478ebdc65 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -35,6 +35,7 @@ PHP                                                                        NEWS
 - Fixed bug #32947 (Incorrect option for mysqli default password). (Georg)
 - Fixed bug #32944 (Disabling session.use_cookies doesn't prevent reading 
   session cookies). (Jani, Tony)
+- Fixed bug #32941 (Sending structured SOAP fault kills a php). (Dmitry)
 - Fixed bug #32936 (http redirects URLs are not checked for control chars). (Ilia)
 - Fixed bug #32933 (Cannot extend class "SQLiteDatabase"). (Marcus)
 - Fixed bug #32932 (Oracle LDAP: ldap_get_entries(), invalid pointer). (Jani)
index b9027ddd4eac3fd177d48986b37a87ea0987dc08..a0b5f7aa91c32d2349aa242a839bca0d6368b349 100644 (file)
@@ -2297,6 +2297,9 @@ static zval *guess_zval_convert(encodeTypePtr type, xmlNodePtr data)
                if (tmpattr != NULL) {
                  type_name = tmpattr->children->content;
                        enc = get_encoder_from_prefix(SOAP_GLOBAL(sdl), data, tmpattr->children->content);
+                       if (type == &enc->details) {
+                               enc = NULL;
+                       }
                        if (enc != NULL) {
                          encodePtr tmp = enc;
                          while (tmp &&
index b292a60862d4f3413a98975db433d1508e804394..10119a45de3507a54f860ba5c82bb5a70081be3f 100644 (file)
@@ -88,20 +88,10 @@ static encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns,
 
 static encodePtr get_create_encoder(sdlPtr sdl, sdlTypePtr cur_type, const char *ns, const char *type)
 {
-       encodePtr enc = NULL;
-       smart_str nscat = {0};
-
-       smart_str_appends(&nscat, ns);
-       smart_str_appendc(&nscat, ':');
-       smart_str_appends(&nscat, type);
-       smart_str_0(&nscat);
-
-       enc = get_encoder_ex(sdl, nscat.c, nscat.len);
+       encodePtr enc = get_encoder(sdl, ns, type);
        if (enc == NULL) {
                enc = create_encoder(sdl, cur_type, ns, type);
        }
-
-       smart_str_free(&nscat);
        return enc;
 }
 
index ca71ce7ced16e4252e1d0ea004bf627dd2db73a0..25022c80ea3c616605314b98d5b435998f00a165 100644 (file)
@@ -50,21 +50,10 @@ encodePtr get_encoder_from_prefix(sdlPtr sdl, xmlNodePtr node, const char *type)
        parse_namespace(type, &cptype, &ns);
        nsptr = xmlSearchNs(node->doc, node, ns);
        if (nsptr != NULL) {
-               int ns_len = strlen(nsptr->href);
-               int type_len = strlen(cptype);
-               int len = ns_len + type_len + 1;
-               char *nscat = emalloc(len + 1);
-
-               memcpy(nscat, nsptr->href, ns_len);
-               nscat[ns_len] = ':';
-               memcpy(nscat+ns_len+1, cptype, type_len);
-               nscat[len] = '\0';
-
-               enc = get_encoder_ex(sdl, nscat, len);
+               enc = get_encoder(sdl, nsptr->href, cptype);
                if (enc == NULL) {
-                       enc = get_encoder_ex(sdl, type, type_len);
+                       enc = get_encoder_ex(sdl, cptype, strlen(cptype));
                }
-               efree(nscat);
        } else {
                enc = get_encoder_ex(sdl, type, strlen(type));
        }
@@ -128,8 +117,24 @@ encodePtr get_encoder(sdlPtr sdl, const char *ns, const char *type)
        nscat[len] = '\0';
 
        enc = get_encoder_ex(sdl, nscat, len);
-
        efree(nscat);
+
+       if (enc == NULL &&
+           ((ns_len == sizeof(SOAP_1_1_ENC_NAMESPACE)-1 &&
+             memcmp(ns, SOAP_1_1_ENC_NAMESPACE, sizeof(SOAP_1_1_ENC_NAMESPACE)-1) == 0) ||
+            (ns_len == sizeof(SOAP_1_2_ENC_NAMESPACE)-1 &&
+             memcmp(ns, SOAP_1_2_ENC_NAMESPACE, sizeof(SOAP_1_2_ENC_NAMESPACE)-1) == 0))) {
+               ns_len = sizeof(XSD_NAMESPACE)-1;
+               len = ns_len + type_len + 1;
+               nscat = emalloc(len + 1);
+               memcpy(nscat, XSD_NAMESPACE, sizeof(XSD_NAMESPACE)-1);
+               nscat[ns_len] = ':';
+               memcpy(nscat+ns_len+1, type, type_len);
+               nscat[len] = '\0';
+
+               enc = get_encoder_ex(sdl, nscat, len);
+               efree(nscat);
+       }
        return enc;
 }
 
diff --git a/ext/soap/tests/bugs/bug32941.phpt b/ext/soap/tests/bugs/bug32941.phpt
new file mode 100755 (executable)
index 0000000..5fd17df
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+Bug #32941 (Sending structured exception kills a php)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+class TestSoapClient extends SoapClient {
+  function __doRequest($request, $location, $action, $version) {
+       return <<<EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<soapenv:Envelope
+xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+       <soapenv:Body>
+               <soapenv:Fault>
+                       <faultcode>soapenv:Server.userException</faultcode>
+                       <faultstring>service.EchoServiceException</faultstring>
+                       <detail>
+                               <service.EchoServiceException xsi:type="ns1:EchoServiceException" xmlns:ns1="urn:service.EchoService">
+                                       <intParameter xsi:type="xsd:int">105</intParameter>
+                                       <parameter xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">string param</parameter>
+                               </service.EchoServiceException>
+                               <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">steckovic</ns2:hostname>
+                       </detail>
+               </soapenv:Fault>
+       </soapenv:Body>
+</soapenv:Envelope>
+EOF;
+       }
+}
+
+ini_set("soap.wsdl_cache_enabled", 1);
+$client = new TestSoapClient(dirname(__FILE__).'/bug32941.wsdl', array("trace" => 1, 'exceptions' => 0));
+$ahoj = $client->echoString('exception');
+$client = new TestSoapClient(dirname(__FILE__).'/bug32941.wsdl', array("trace" => 1, 'exceptions' => 0));
+$ahoj = $client->echoString('exception');
+echo "ok\n";
+?>
+--EXPECT--
+ok
diff --git a/ext/soap/tests/bugs/bug32941.wsdl b/ext/soap/tests/bugs/bug32941.wsdl
new file mode 100755 (executable)
index 0000000..61fd13d
--- /dev/null
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<wsdl:definitions targetNamespace="http://212.24.157.117:8080/axis/services/echo" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://212.24.157.117:8080/axis/services/echo" xmlns:intf="http://212.24.157.117:8080/axis/services/echo" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="urn:service.EchoService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">\r
+<!--WSDL created by Apache Axis version: 1.2RC3
+Built on Feb 28, 2005 (10:15:14 EST)-->\r
+ <wsdl:types>\r
+  <schema targetNamespace="urn:service.EchoService" xmlns="http://www.w3.org/2001/XMLSchema">\r
+   <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>\r
+   <complexType name="EchoServiceException">\r
+    <sequence>\r
+     <element name="intParameter" type="xsd:int"/>\r
+     <element name="parameter" nillable="true" type="soapenc:string"/>\r
+    </sequence>\r
+   </complexType>\r
+   <complexType name="Person">\r
+    <sequence>\r
+     <element name="name" nillable="true" type="soapenc:string"/>\r
+     <element name="surname" nillable="true" type="soapenc:string"/>\r
+    </sequence>\r
+   </complexType>\r
+  </schema>\r
+ </wsdl:types>\r
+
+   <wsdl:message name="echoStringResponse">\r
+
+      <wsdl:part name="echoStringReturn" type="soapenc:string"/>\r
+
+   </wsdl:message>\r
+
+   <wsdl:message name="EchoServiceException">\r
+
+      <wsdl:part name="EchoServiceException" type="tns1:EchoServiceException"/>\r
+
+   </wsdl:message>\r
+
+   <wsdl:message name="echoStringRequest">\r
+
+      <wsdl:part name="e" type="xsd:string"/>\r
+
+   </wsdl:message>\r
+
+   <wsdl:message name="echoPersonResponse">\r
+
+      <wsdl:part name="echoPersonReturn" type="tns1:Person"/>\r
+
+   </wsdl:message>\r
+
+   <wsdl:message name="echoPersonRequest">\r
+
+      <wsdl:part name="p" type="tns1:Person"/>\r
+
+   </wsdl:message>\r
+
+   <wsdl:portType name="EchoService">\r
+
+      <wsdl:operation name="echoString" parameterOrder="e">\r
+
+         <wsdl:input message="impl:echoStringRequest" name="echoStringRequest"/>\r
+
+         <wsdl:output message="impl:echoStringResponse" name="echoStringResponse"/>\r
+
+         <wsdl:fault message="impl:EchoServiceException" name="EchoServiceException"/>\r
+
+      </wsdl:operation>\r
+
+      <wsdl:operation name="echoPerson" parameterOrder="p">\r
+
+         <wsdl:input message="impl:echoPersonRequest" name="echoPersonRequest"/>\r
+
+         <wsdl:output message="impl:echoPersonResponse" name="echoPersonResponse"/>\r
+
+         <wsdl:fault message="impl:EchoServiceException" name="EchoServiceException"/>\r
+
+      </wsdl:operation>\r
+
+   </wsdl:portType>\r
+
+   <wsdl:binding name="echoSoapBinding" type="impl:EchoService">\r
+
+      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>\r
+
+      <wsdl:operation name="echoString">\r
+
+         <wsdlsoap:operation soapAction=""/>\r
+
+         <wsdl:input name="echoStringRequest">\r
+
+            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:service.EchoService" use="encoded"/>\r
+
+         </wsdl:input>\r
+
+         <wsdl:output name="echoStringResponse">\r
+
+            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://212.24.157.117:8080/axis/services/echo" use="encoded"/>\r
+
+         </wsdl:output>\r
+
+         <wsdl:fault name="EchoServiceException">\r
+
+            <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="EchoServiceException" namespace="urn:service.EchoService" use="encoded"/>\r
+
+         </wsdl:fault>\r
+
+      </wsdl:operation>\r
+
+      <wsdl:operation name="echoPerson">\r
+
+         <wsdlsoap:operation soapAction=""/>\r
+
+         <wsdl:input name="echoPersonRequest">\r
+
+            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://service" use="encoded"/>\r
+
+         </wsdl:input>\r
+
+         <wsdl:output name="echoPersonResponse">\r
+
+            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://212.24.157.117:8080/axis/services/echo" use="encoded"/>\r
+
+         </wsdl:output>\r
+
+         <wsdl:fault name="EchoServiceException">\r
+
+            <wsdlsoap:fault encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" name="EchoServiceException" namespace="http://212.24.157.117:8080/axis/services/echo" use="encoded"/>\r
+
+         </wsdl:fault>\r
+
+      </wsdl:operation>\r
+
+   </wsdl:binding>\r
+
+   <wsdl:service name="EchoServiceService">\r
+
+      <wsdl:port binding="impl:echoSoapBinding" name="echo">\r
+
+         <wsdlsoap:address location="http://212.24.157.117:8080/axis/services/echo"/>\r
+
+      </wsdl:port>\r
+
+   </wsdl:service>\r
+
+</wsdl:definitions>\r