Skip to content

Commit

Permalink
Fixed issue #1629: SOAP Client/Server detection code does not handle …
Browse files Browse the repository at this point in the history
…inherited classes
  • Loading branch information
derickr committed Feb 11, 2019
1 parent 606f0d9 commit d96dc3a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
25 changes: 25 additions & 0 deletions tests/bug01629.phpt
@@ -0,0 +1,25 @@
--TEST--
Test for bug #1629: SOAP Client/Server detection code does not handle inherited classes
--SKIPIF--
<?php
if (!extension_loaded("soap")) { echo "skip SOAP extension required\n"; }
?>
--FILE--
<?php
class SoapAgent extends \SoapClient
{
public function __construct(string $wsdl)
{
try {
parent::__construct($wsdl);
echo 'Success!' . PHP_EOL;
} catch (\Throwable $t) {
echo $t->GetMessage(), "\n";
}
}
}

$client = new SoapAgent('test');
?>
--EXPECT--
SOAP-ERROR: Parsing WSDL: Couldn't load from 'test' : failed to load external entity "test"
29 changes: 21 additions & 8 deletions xdebug.c
Expand Up @@ -1950,16 +1950,29 @@ void xdebug_execute_ex(zend_execute_data *execute_data TSRMLS_DC)
XG(level)--;
}

static int check_soap_call(function_stack_entry *fse)
static int check_soap_call(function_stack_entry *fse, zend_execute_data *execute_data)
{
if (fse->function.class &&
(
(strstr(fse->function.class, "SoapClient") != NULL) ||
(strstr(fse->function.class, "SoapServer") != NULL)
) &&
if (
fse->function.class &&
Z_OBJ(EX(This)) &&
Z_TYPE(EX(This)) == IS_OBJECT &&
(zend_hash_str_find_ptr(&module_registry, "soap", sizeof("soap") - 1) != NULL)
) {
return 1;
zend_class_entry *soap_server_ce, *soap_client_ce;

soap_server_ce = zend_hash_str_find_ptr(CG(class_table), "soapserver", 10);
soap_client_ce = zend_hash_str_find_ptr(CG(class_table), "soapclient", 10);

if (!soap_server_ce || !soap_client_ce) {
return 0;
}

if (
(instanceof_function(Z_OBJCE(EX(This)), soap_server_ce)) ||
(instanceof_function(Z_OBJCE(EX(This)), soap_client_ce))
) {
return 1;
}
}
return 0;
}
Expand Down Expand Up @@ -1996,7 +2009,7 @@ void xdebug_execute_internal(zend_execute_data *current_execute_data, zval *retu
}

/* Check for SOAP */
if (check_soap_call(fse)) {
if (check_soap_call(fse, current_execute_data)) {
restore_error_handler_situation = 1;
tmp_error_cb = zend_error_cb;
zend_error_cb = xdebug_old_error_cb;
Expand Down

0 comments on commit d96dc3a

Please sign in to comment.