Skip to content

Commit cd61f16

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

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
@@ -2451,16 +2451,17 @@ static void do_soap_call(zend_execute_data *execute_data,
24512451
}
24522452
/* }}} */
24532453

2454-
static void verify_soap_headers_array(HashTable *ht) /* {{{ */
2454+
static bool verify_soap_headers_array(const HashTable *ht) /* {{{ */
24552455
{
24562456
zval *tmp;
24572457

24582458
ZEND_HASH_FOREACH_VAL(ht, tmp) {
24592459
if (Z_TYPE_P(tmp) != IS_OBJECT ||
24602460
!instanceof_function(Z_OBJCE_P(tmp), soap_header_class_entry)) {
2461-
php_error_docref(NULL, E_ERROR, "Invalid SOAP header");
2461+
return false;
24622462
}
24632463
} ZEND_HASH_FOREACH_END();
2464+
return true;
24642465
}
24652466
/* }}} */
24662467

@@ -2593,7 +2594,9 @@ PHP_METHOD(SoapClient, __soapCall)
25932594
if (headers == NULL || Z_TYPE_P(headers) == IS_NULL) {
25942595
} else if (Z_TYPE_P(headers) == IS_ARRAY) {
25952596
soap_headers = Z_ARRVAL_P(headers);
2596-
verify_soap_headers_array(soap_headers);
2597+
if (!verify_soap_headers_array(soap_headers)) {
2598+
php_error_docref(NULL, E_ERROR, "Invalid SOAP header");
2599+
}
25972600
free_soap_headers = false;
25982601
} else if (Z_TYPE_P(headers) == IS_OBJECT && instanceof_function(Z_OBJCE_P(headers), soap_header_class_entry)) {
25992602
soap_headers = zend_new_array(0);
@@ -2802,7 +2805,9 @@ PHP_METHOD(SoapClient, __setSoapHeaders)
28022805
if (headers == NULL || Z_TYPE_P(headers) == IS_NULL) {
28032806
convert_to_null(Z_CLIENT_DEFAULT_HEADERS_P(this_ptr));
28042807
} else if (Z_TYPE_P(headers) == IS_ARRAY) {
2805-
verify_soap_headers_array(Z_ARRVAL_P(headers));
2808+
if (!verify_soap_headers_array(Z_ARRVAL_P(headers))) {
2809+
php_error_docref(NULL, E_ERROR, "Invalid SOAP header");
2810+
}
28062811
zval_ptr_dtor(Z_CLIENT_DEFAULT_HEADERS_P(this_ptr));
28072812
ZVAL_COPY(Z_CLIENT_DEFAULT_HEADERS_P(this_ptr), headers);
28082813
} else if (Z_TYPE_P(headers) == IS_OBJECT &&

0 commit comments

Comments
 (0)