Skip to content

Commit a405241

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

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
@@ -2437,16 +2437,17 @@ static void do_soap_call(zend_execute_data *execute_data,
24372437
}
24382438
/* }}} */
24392439

2440-
static void verify_soap_headers_array(HashTable *ht) /* {{{ */
2440+
static bool verify_soap_headers_array(const HashTable *ht) /* {{{ */
24412441
{
24422442
zval *tmp;
24432443

24442444
ZEND_HASH_FOREACH_VAL(ht, tmp) {
24452445
if (Z_TYPE_P(tmp) != IS_OBJECT ||
24462446
!instanceof_function(Z_OBJCE_P(tmp), soap_header_class_entry)) {
2447-
php_error_docref(NULL, E_ERROR, "Invalid SOAP header");
2447+
return false;
24482448
}
24492449
} ZEND_HASH_FOREACH_END();
2450+
return true;
24502451
}
24512452
/* }}} */
24522453

@@ -2579,7 +2580,9 @@ PHP_METHOD(SoapClient, __soapCall)
25792580
if (headers == NULL || Z_TYPE_P(headers) == IS_NULL) {
25802581
} else if (Z_TYPE_P(headers) == IS_ARRAY) {
25812582
soap_headers = Z_ARRVAL_P(headers);
2582-
verify_soap_headers_array(soap_headers);
2583+
if (!verify_soap_headers_array(soap_headers)) {
2584+
php_error_docref(NULL, E_ERROR, "Invalid SOAP header");
2585+
}
25832586
free_soap_headers = false;
25842587
} else if (Z_TYPE_P(headers) == IS_OBJECT && instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry)) {
25852588
soap_headers = zend_new_array(0);
@@ -2788,7 +2791,9 @@ PHP_METHOD(SoapClient, __setSoapHeaders)
27882791
if (headers == NULL || Z_TYPE_P(headers) == IS_NULL) {
27892792
convert_to_null(Z_CLIENT_DEFAULT_HEADERS_P(this_ptr));
27902793
} else if (Z_TYPE_P(headers) == IS_ARRAY) {
2791-
verify_soap_headers_array(Z_ARRVAL_P(headers));
2794+
if (!verify_soap_headers_array(Z_ARRVAL_P(headers))) {
2795+
php_error_docref(NULL, E_ERROR, "Invalid SOAP header");
2796+
}
27922797
zval_ptr_dtor(Z_CLIENT_DEFAULT_HEADERS_P(this_ptr));
27932798
ZVAL_COPY(Z_CLIENT_DEFAULT_HEADERS_P(this_ptr), headers);
27942799
} else if (Z_TYPE_P(headers) == IS_OBJECT &&

0 commit comments

Comments
 (0)