Skip to content

Commit d40b759

Browse files
committed
Fix segfault raise by bad from_xml callback
1 parent d9329b1 commit d40b759

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

ext/soap/php_packet_soap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
192192
if (tmp != NULL && tmp->children != NULL) {
193193
zval zv;
194194
master_to_zval(&zv, get_conversion(IS_STRING), tmp);
195-
faultstring = Z_STR(zv);
195+
faultstring = zval_get_string_func(&zv);
196196
}
197197

198198
tmp = get_node(fault->children, "faultactor");
@@ -222,7 +222,7 @@ int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunction
222222
if (tmp != NULL && tmp->children != NULL) {
223223
zval zv;
224224
master_to_zval(&zv, get_conversion(IS_STRING), tmp);
225-
faultstring = Z_STR(zv);
225+
faultstring = zval_get_string_func(&zv);
226226
}
227227
}
228228

ext/soap/tests/typemap014.phpt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
--TEST--
2+
SOAP typemap 14: typemap bad from_xml callback raise segfault
3+
--EXTENSIONS--
4+
soap
5+
--INI--
6+
soap.wsdl_cache_enabled=0
7+
--FILE--
8+
<?php
9+
function soap_string_from_xml($str)
10+
{
11+
echo "soap_string_from_xml\n";
12+
13+
// Should return an object
14+
return 2.3;
15+
}
16+
17+
class TestSoapClient extends SoapClient {
18+
function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
19+
$res='<?xml version="1.0" encoding="UTF-8"?>
20+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
21+
<SOAP-ENV:Body>
22+
<SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>not present</faultstring>
23+
</SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>';
24+
return $res;
25+
}
26+
}
27+
28+
try {
29+
$client=new TestSoapClient(null, [
30+
'uri' => 'test://',
31+
'location' => 'test://',
32+
'typemap' => [[
33+
"type_ns" => "http://www.w3.org/2001/XMLSchema",
34+
"type_name" => "string",
35+
"from_xml" => "soap_string_from_xml"
36+
]]]);
37+
$client->Mist("");
38+
} catch (SoapFault $e) {
39+
var_dump($e->faultstring);
40+
var_dump($e->faultcode);
41+
}
42+
?>
43+
Done
44+
--EXPECT--
45+
soap_string_from_xml
46+
string(3) "2.3"
47+
string(15) "SOAP-ENV:Server"
48+
Done

0 commit comments

Comments
 (0)