Skip to content

Commit 86de4d7

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix bug #80672 - Null Dereference in SoapClient
2 parents aeb4f21 + 3c939e3 commit 86de4d7

File tree

4 files changed

+37
-14
lines changed

4 files changed

+37
-14
lines changed

ext/soap/php_sdl.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ void sdl_restore_uri_credentials(sdlCtx *ctx)
315315
ctx->context = NULL;
316316
}
317317

318+
#define SAFE_STR(a) ((a)?a:"")
319+
318320
static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include)
319321
{
320322
sdlPtr tmpsdl = ctx->sdl;
@@ -376,7 +378,7 @@ static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include)
376378
if (node_is_equal_ex(trav2, "schema", XSD_NAMESPACE)) {
377379
load_schema(ctx, trav2);
378380
} else if (is_wsdl_element(trav2) && !node_is_equal(trav2,"documentation")) {
379-
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", trav2->name);
381+
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", SAFE_STR(trav2->name));
380382
}
381383
trav2 = trav2->next;
382384
}
@@ -437,7 +439,7 @@ static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include)
437439
soap_error0(E_ERROR, "Parsing WSDL: <service> has no name attribute");
438440
}
439441
} else if (!node_is_equal(trav,"documentation")) {
440-
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", trav->name);
442+
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", SAFE_STR(trav->name));
441443
}
442444
trav = trav->next;
443445
}
@@ -547,7 +549,7 @@ static sdlSoapBindingFunctionHeaderPtr wsdl_soap_binding_header(sdlCtx* ctx, xml
547549
}
548550
smart_str_free(&key);
549551
} else if (is_wsdl_element(trav) && !node_is_equal(trav,"documentation")) {
550-
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", trav->name);
552+
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", SAFE_STR(trav->name));
551553
}
552554
trav = trav->next;
553555
}
@@ -649,7 +651,7 @@ static void wsdl_soap_binding_body(sdlCtx* ctx, xmlNodePtr node, char* wsdl_soap
649651
}
650652
smart_str_free(&key);
651653
} else if (is_wsdl_element(trav) && !node_is_equal(trav,"documentation")) {
652-
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", trav->name);
654+
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", SAFE_STR(trav->name));
653655
}
654656
trav = trav->next;
655657
}
@@ -681,14 +683,14 @@ static HashTable* wsdl_message(sdlCtx *ctx, xmlChar* message_name)
681683
sdlParamPtr param;
682684

683685
if (trav->ns != NULL && strcmp((char*)trav->ns->href, WSDL_NAMESPACE) != 0) {
684-
soap_error1(E_ERROR, "Parsing WSDL: Unexpected extensibility element <%s>", trav->name);
686+
soap_error1(E_ERROR, "Parsing WSDL: Unexpected extensibility element <%s>", SAFE_STR(trav->name));
685687
}
686688
if (node_is_equal(trav,"documentation")) {
687689
trav = trav->next;
688690
continue;
689691
}
690692
if (!node_is_equal(trav,"part")) {
691-
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", trav->name);
693+
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", SAFE_STR(trav->name));
692694
}
693695
part = trav;
694696
param = emalloc(sizeof(sdlParam));
@@ -697,7 +699,7 @@ static HashTable* wsdl_message(sdlCtx *ctx, xmlChar* message_name)
697699

698700
name = get_attribute(part->properties, "name");
699701
if (name == NULL) {
700-
soap_error1(E_ERROR, "Parsing WSDL: No name associated with <part> '%s'", message->name);
702+
soap_error1(E_ERROR, "Parsing WSDL: No name associated with <part> '%s'", SAFE_STR(message->name));
701703
}
702704

703705
param->paramName = estrdup((char*)name->children->content);
@@ -768,7 +770,7 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
768770
continue;
769771
}
770772
if (!node_is_equal(trav,"port")) {
771-
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", trav->name);
773+
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", SAFE_STR(trav->name));
772774
}
773775

774776
port = trav;
@@ -807,7 +809,7 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
807809
}
808810
}
809811
if (trav2 != address && is_wsdl_element(trav2) && !node_is_equal(trav2,"documentation")) {
810-
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", trav2->name);
812+
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", SAFE_STR(trav2->name));
811813
}
812814
trav2 = trav2->next;
813815
}
@@ -909,7 +911,7 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
909911
continue;
910912
}
911913
if (!node_is_equal(trav2,"operation")) {
912-
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", trav2->name);
914+
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", SAFE_STR(trav2->name));
913915
}
914916

915917
operation = trav2;
@@ -928,7 +930,7 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
928930
!node_is_equal(trav3,"output") &&
929931
!node_is_equal(trav3,"fault") &&
930932
!node_is_equal(trav3,"documentation")) {
931-
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", trav3->name);
933+
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", SAFE_STR(trav3->name));
932934
}
933935
trav3 = trav3->next;
934936
}
@@ -1106,7 +1108,7 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
11061108
}
11071109
}
11081110
} else if (is_wsdl_element(trav) && !node_is_equal(trav,"documentation")) {
1109-
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", trav->name);
1111+
soap_error1(E_ERROR, "Parsing WSDL: Unexpected WSDL element <%s>", SAFE_STR(trav->name));
11101112
}
11111113
trav = trav->next;
11121114
}

ext/soap/php_xml.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ xmlNsPtr node_find_ns(xmlNodePtr node)
199199

200200
int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns)
201201
{
202-
if (name == NULL || strcmp((char*)node->name, name) == 0) {
202+
if (name == NULL || ((node->name) && strcmp((char*)node->name, name) == 0)) {
203203
if (ns) {
204204
xmlNsPtr nsPtr = attr_find_ns(node);
205205
if (nsPtr) {
@@ -215,7 +215,7 @@ int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns)
215215

216216
int node_is_equal_ex(xmlNodePtr node, char *name, char *ns)
217217
{
218-
if (name == NULL || strcmp((char*)node->name, name) == 0) {
218+
if (name == NULL || ((node->name) && strcmp((char*)node->name, name) == 0)) {
219219
if (ns) {
220220
xmlNsPtr nsPtr = node_find_ns(node);
221221
if (nsPtr) {

ext/soap/tests/bug80672.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #80672 Null Dereference in SoapClient
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
try {
8+
$client = new SoapClient(__DIR__ . "/bug80672.xml");
9+
$query = $soap->query(array('sXML' => 'something'));
10+
} catch(SoapFault $e) {
11+
print $e->getMessage();
12+
}
13+
?>
14+
--EXPECTF--
15+
SOAP-ERROR: Parsing WSDL: Unexpected WSDL element <>

ext/soap/tests/bug80672.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="ISO-8859-1"?>
2+
<soap:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/">
5+
<![CDATA[test]]>
6+
</soap:definitions>

0 commit comments

Comments
 (0)