]> granicus.if.org Git - php/commitdiff
Fixed bug #29795 (SegFault with Soap and Amazon's Web Services)
authorDmitry Stogov <dmitry@php.net>
Thu, 26 Aug 2004 15:26:32 +0000 (15:26 +0000)
committerDmitry Stogov <dmitry@php.net>
Thu, 26 Aug 2004 15:26:32 +0000 (15:26 +0000)
Fixed bug #27994 (segfault with Soapserver when WSDL-Cache is enabled)

ext/soap/php_encoding.c
ext/soap/tests/bugs/bug29795.phpt [new file with mode: 0644]
ext/soap/tests/bugs/bug29795.wsdl [new file with mode: 0644]

index 08e80c223f67a127ecce5050c848464dbacf2acf..05e2d5143c6675486d425505bb882fc56d3b38e5 100644 (file)
@@ -2437,6 +2437,9 @@ zval *sdl_guess_convert_zval(encodeTypePtr enc, xmlNodePtr data)
        sdlTypePtr type;
 
        type = enc->sdl_type;
+       if (type == NULL) {
+               return guess_zval_convert(enc, data);
+       }
 /*FIXME: restriction support
        if (type && type->restrictions &&
            data &&  data->children && data->children->content) {
@@ -2500,6 +2503,13 @@ xmlNodePtr sdl_guess_convert_xml(encodeTypePtr enc, zval *data, int style, xmlNo
 
        type = enc->sdl_type;
 
+       if (type == NULL) {
+               ret = guess_xml_convert(enc, data, style, parent);
+               if (style == SOAP_ENCODED) {
+                       set_ns_and_type(ret, enc);
+               }
+               return ret;
+       }
 /*FIXME: restriction support
        if (type) {
                if (type->restrictions && Z_TYPE_P(data) == IS_STRING) {
diff --git a/ext/soap/tests/bugs/bug29795.phpt b/ext/soap/tests/bugs/bug29795.phpt
new file mode 100644 (file)
index 0000000..f32d16a
--- /dev/null
@@ -0,0 +1,32 @@
+--TEST--
+Bug #29795 (SegFault with Soap and Amazon's Web Services)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+class LocalSoapClient extends SoapClient {
+
+  function LocalSoapClient($wsdl, $options) {
+    $this->SoapClient($wsdl, $options);
+  }
+
+  function __doRequest($request, $location, $action, $version) {
+    return <<<EOF
+<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
+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:Body><Price><Amount>3995</Amount><CurrencyCode>USD</CurrencyCode></Price></SOAP-ENV:Body></SOAP-ENV:Envelope>
+EOF;
+  }
+
+}
+
+$client = new LocalSoapClient(dirname(__FILE__)."/bug29795.wsdl",array("trace"=>1));
+$ar=$client->GetPrice();
+echo "o";
+$client = new LocalSoapClient(dirname(__FILE__)."/bug29795.wsdl",array("trace"=>1));
+$ar=$client->GetPrice();
+echo "k\n";
+?>
+--EXPECT--
+ok
diff --git a/ext/soap/tests/bugs/bug29795.wsdl b/ext/soap/tests/bugs/bug29795.wsdl
new file mode 100644 (file)
index 0000000..5a4499d
--- /dev/null
@@ -0,0 +1,40 @@
+<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://xml.amazon.com/AWSProductData/2004-08-01" targetNamespace="http://xml.amazon.com/AWSProductData/2004-08-01">\r
+       <types>\r
+               <xs:schema targetNamespace="http://xml.amazon.com/AWSProductData/2004-08-01" elementFormDefault="qualified">\r
+                       <xs:complexType name="Price">\r
+                               <xs:sequence>\r
+                                       <xs:element name="Amount" type="xs:integer" minOccurs="0"/>\r
+                                       <xs:element name="CurrencyCode" type="xs:string" minOccurs="0"/>\r
+                               </xs:sequence>\r
+                       </xs:complexType>\r
+               </xs:schema>\r
+       </types>\r
+       <message name="GetPriceRequest">\r
+       </message>\r
+       <message name="GetPriceResponse">\r
+               <part name="Price" type="tns:Price"/>\r
+       </message>\r
+       <portType name="AWSProductDataPortType">\r
+               <operation name="GetPrice">\r
+                       <input message="tns:GetPriceRequest"/>\r
+                       <output message="tns:GetPriceResponse"/>\r
+               </operation>\r
+       </portType>\r
+       <binding name="AWSProductDataBinding" type="tns:AWSProductDataPortType">\r
+               <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>\r
+               <operation name="GetPrice">\r
+                       <soap:operation soapAction="http://soap.amazon.com"/>\r
+                       <input>\r
+                               <soap:body use="literal"/>\r
+                       </input>\r
+                       <output>\r
+                               <soap:body use="literal"/>\r
+                       </output>\r
+               </operation>\r
+       </binding>\r
+       <service name="AWSProductData">\r
+               <port name="AWSProductDataPort" binding="tns:AWSProductDataBinding">\r
+                       <soap:address location="http://aws-beta.amazon.com/onca/soap?Service=AWSProductData"/>\r
+               </port>\r
+       </service>\r
+</definitions>\r