Skip to content

Commit c2d344c

Browse files
committed
ext/soap: Refactor verify_soap_headers_array()
Make its duty only to check if the provided HashTable is valid
1 parent 812e43b commit c2d344c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ext/soap/soap.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,16 +2457,17 @@ static void do_soap_call(zend_execute_data *execute_data,
24572457
}
24582458
/* }}} */
24592459

2460-
static void verify_soap_headers_array(HashTable *ht) /* {{{ */
2460+
static bool verify_soap_headers_array(const HashTable *ht) /* {{{ */
24612461
{
24622462
zval *tmp;
24632463

24642464
ZEND_HASH_FOREACH_VAL(ht, tmp) {
24652465
if (Z_TYPE_P(tmp) != IS_OBJECT ||
24662466
!instanceof_function(Z_OBJCE_P(tmp), soap_header_class_entry)) {
2467-
php_error_docref(NULL, E_ERROR, "Invalid SOAP header");
2467+
return false;
24682468
}
24692469
} ZEND_HASH_FOREACH_END();
2470+
return true;
24702471
}
24712472
/* }}} */
24722473

@@ -2599,7 +2600,9 @@ PHP_METHOD(SoapClient, __soapCall)
25992600
if (headers == NULL || Z_TYPE_P(headers) == IS_NULL) {
26002601
} else if (Z_TYPE_P(headers) == IS_ARRAY) {
26012602
soap_headers = Z_ARRVAL_P(headers);
2602-
verify_soap_headers_array(soap_headers);
2603+
if (!verify_soap_headers_array(soap_headers)) {
2604+
php_error_docref(NULL, E_ERROR, "Invalid SOAP header");
2605+
}
26032606
free_soap_headers = false;
26042607
} else if (Z_TYPE_P(headers) == IS_OBJECT && instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry)) {
26052608
soap_headers = zend_new_array(0);
@@ -2808,7 +2811,9 @@ PHP_METHOD(SoapClient, __setSoapHeaders)
28082811
if (headers == NULL || Z_TYPE_P(headers) == IS_NULL) {
28092812
convert_to_null(Z_CLIENT_DEFAULT_HEADERS_P(this_ptr));
28102813
} else if (Z_TYPE_P(headers) == IS_ARRAY) {
2811-
verify_soap_headers_array(Z_ARRVAL_P(headers));
2814+
if (!verify_soap_headers_array(Z_ARRVAL_P(headers))) {
2815+
php_error_docref(NULL, E_ERROR, "Invalid SOAP header");
2816+
}
28122817
zval_ptr_dtor(Z_CLIENT_DEFAULT_HEADERS_P(this_ptr));
28132818
ZVAL_COPY(Z_CLIENT_DEFAULT_HEADERS_P(this_ptr), headers);
28142819
} else if (Z_TYPE_P(headers) == IS_OBJECT &&

0 commit comments

Comments
 (0)