Skip to content

Fix memory leaks with string function name lookups #14390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions ext/soap/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@ PHP_METHOD(SoapServer, addFunction)
key = zend_string_tolower(Z_STR_P(tmp_function));

if ((f = zend_hash_find_ptr(EG(function_table), key)) == NULL) {
zend_string_release_ex(key, false);
zend_type_error("SoapServer::addFunction(): Function \"%s\" not found", Z_STRVAL_P(tmp_function));
SOAP_SERVER_END_CODE();
RETURN_THROWS();
Expand All @@ -1069,6 +1070,7 @@ PHP_METHOD(SoapServer, addFunction)
key = zend_string_tolower(Z_STR_P(function_name));

if ((f = zend_hash_find_ptr(EG(function_table), key)) == NULL) {
zend_string_release_ex(key, false);
zend_argument_type_error(1, "must be a valid function name, function \"%s\" not found", Z_STRVAL_P(function_name));
SOAP_SERVER_END_CODE();
RETURN_THROWS();
Expand Down Expand Up @@ -1395,8 +1397,7 @@ PHP_METHOD(SoapServer, handle)
}
}
#endif
zend_string *fn_name = zend_string_tolower(Z_STR(h->function_name));
if (zend_hash_exists(function_table, fn_name) ||
if (zend_hash_find_ptr_lc(function_table, Z_STR(h->function_name)) != NULL ||
((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&
zend_hash_str_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)-1))) {
if (service->type == SOAP_CLASS || service->type == SOAP_OBJECT) {
Expand All @@ -1412,25 +1413,21 @@ PHP_METHOD(SoapServer, handle)
instanceof_function(Z_OBJCE(h->retval), soap_fault_class_entry)) {
php_output_discard();
soap_server_fault_ex(function, &h->retval, h);
zend_string_release(fn_name);
if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(soap_obj);}
goto fail;
} else if (EG(exception)) {
php_output_discard();
_soap_server_exception(service, function, ZEND_THIS);
zend_string_release(fn_name);
if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(soap_obj);}
goto fail;
}
} else if (h->mustUnderstand) {
soap_server_fault("MustUnderstand","Header not understood", NULL, NULL, NULL);
}
zend_string_release(fn_name);
}
}

zend_string *fn_name = zend_string_tolower(Z_STR(function_name));
if (zend_hash_exists(function_table, fn_name) ||
if (zend_hash_find_ptr_lc(function_table, Z_STR(function_name)) != NULL ||
((service->type == SOAP_CLASS || service->type == SOAP_OBJECT) &&
zend_hash_str_exists(function_table, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME)-1))) {
if (service->type == SOAP_CLASS || service->type == SOAP_OBJECT) {
Expand All @@ -1452,7 +1449,6 @@ PHP_METHOD(SoapServer, handle)
} else {
php_error(E_ERROR, "Function '%s' doesn't exist", Z_STRVAL(function_name));
}
zend_string_release(fn_name);

if (EG(exception)) {
if (!zend_is_unwind_exit(EG(exception))) {
Expand Down
Loading