Skip to content

Commit aaafd79

Browse files
committed
Fixed bug #77088 (Segfault when using SoapClient with null options)
SoapClient constructor has its own error handler
1 parent efeb810 commit aaafd79

File tree

3 files changed

+73
-4
lines changed

3 files changed

+73
-4
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug #71041 (zend_signal_startup() needs ZEND_API).
77
(Valentin V. Bartenev)
88

9+
- Soap:
10+
. Fixed bug #77088 (Segfault when using SoapClient with null options).
11+
(Laruence)
12+
913
- Sockets:
1014
. Fixed bug #77136 (Unsupported IPV6_RECVPKTINFO constants on macOS).
1115
(Mizunashi Mana)

ext/soap/soap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,8 +1117,8 @@ PHP_METHOD(SoapServer, SoapServer)
11171117

11181118
SOAP_SERVER_BEGIN_CODE();
11191119

1120-
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "z|a", &wsdl, &options) == FAILURE) {
1121-
return;
1120+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|a", &wsdl, &options) == FAILURE) {
1121+
php_error_docref(NULL, E_ERROR, "Invalid parameters");
11221122
}
11231123

11241124
if (Z_TYPE_P(wsdl) != IS_STRING && Z_TYPE_P(wsdl) != IS_NULL) {
@@ -2273,8 +2273,8 @@ PHP_METHOD(SoapClient, SoapClient)
22732273

22742274
SOAP_CLIENT_BEGIN_CODE();
22752275

2276-
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "z|a", &wsdl, &options) == FAILURE) {
2277-
return;
2276+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|a", &wsdl, &options) == FAILURE) {
2277+
php_error_docref(NULL, E_ERROR, "Invalid parameters");
22782278
}
22792279

22802280
if (Z_TYPE_P(wsdl) != IS_STRING && Z_TYPE_P(wsdl) != IS_NULL) {

ext/soap/tests/bug77088.phpt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
--TEST--
2+
Bug #77088 (Segfault when using SoapClient with null options)
3+
--SKIPIF--
4+
<?php
5+
require_once('skipif.inc');
6+
?>
7+
--FILE--
8+
<?php
9+
10+
try
11+
{
12+
$options = NULL;
13+
$sClient = new SoapClient("test.wsdl", $options);
14+
}
15+
catch(SoapFault $e)
16+
{
17+
var_dump($e);
18+
}
19+
20+
?>
21+
--EXPECTF--
22+
Warning: SoapClient::SoapClient() expects parameter 2 to be array, null given in %sbug77088.php on line %d
23+
object(SoapFault)#%d (%d) {
24+
["message":protected]=>
25+
string(44) "SoapClient::SoapClient(): Invalid parameters"
26+
["string":"Exception":private]=>
27+
string(0) ""
28+
["code":protected]=>
29+
int(0)
30+
["file":protected]=>
31+
string(%d) "%sbug77088.php"
32+
["line":protected]=>
33+
int(6)
34+
["trace":"Exception":private]=>
35+
array(1) {
36+
[0]=>
37+
array(6) {
38+
["file"]=>
39+
string(%d) "%sbug77088.php"
40+
["line"]=>
41+
int(6)
42+
["function"]=>
43+
string(10) "SoapClient"
44+
["class"]=>
45+
string(10) "SoapClient"
46+
["type"]=>
47+
string(2) "->"
48+
["args"]=>
49+
array(2) {
50+
[0]=>
51+
string(9) "test.wsdl"
52+
[1]=>
53+
NULL
54+
}
55+
}
56+
}
57+
["previous":"Exception":private]=>
58+
NULL
59+
["faultstring"]=>
60+
string(44) "SoapClient::SoapClient(): Invalid parameters"
61+
["faultcode"]=>
62+
string(6) "Client"
63+
["faultcodens"]=>
64+
string(41) "http://schemas.xmlsoap.org/soap/envelope/"
65+
}

0 commit comments

Comments
 (0)