xref: /PHP-8.2/ext/soap/tests/bugs/bug66112.phpt (revision 7f2f0c00)
1--TEST--
2Bug #66112 (Use after free condition in SOAP extension)
3--EXTENSIONS--
4soap
5--INI--
6soap.wsdl_cache_enabled=0
7--FILE--
8<?php
9define('WSDL', __DIR__."/bug66112.wsdl");
10function Mist($p) {
11    $client=new soapclient(WSDL, array('typemap'=>array(array("type_ns"=>"uri:mist", "type_name"=>"A"))));
12    try{
13        $client->Mist(array("XX"=>"xx"));
14    }catch(SoapFault $x){
15    }
16    return array("A"=>"ABC","B"=>"sss");
17}
18$s = new SoapServer(WSDL, array('typemap'=>array(array("type_ns"=>"uri:mist", "type_name"=>"A"))));
19$s->addFunction("Mist");
20$_SERVER["REQUEST_METHOD"] = "POST";
21$HTTP_RAW_POST_DATA=<<<EOF
22<?xml version="1.0" encoding="UTF-8"?>
23<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:uri="uri:mist">
24   <soapenv:Header/>
25   <soapenv:Body>
26      <uri:Request><uri:A>XXX</uri:A><uri:B>yyy</uri:B></uri:Request>
27   </soapenv:Body>
28</soapenv:Envelope>
29EOF;
30$s->handle($HTTP_RAW_POST_DATA);
31echo "OK\n";
32?>
33--EXPECT--
34<?xml version="1.0" encoding="UTF-8"?>
35<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="uri:mist"><SOAP-ENV:Body><ns1:Response><A>ABC</A><B>sss</B></ns1:Response></SOAP-ENV:Body></SOAP-ENV:Envelope>
36OK
37