cvs: php-src(PHP_5_2) /ext/xmlrpc xmlrpc-epi-php.c /ext/xmlrpc/tests bug45555.phpt
| From: | Felipe Pena | Date: | Fri, 18 Jul 2008 15:52:38 +0000 |
| Subject: | cvs: php-src(PHP_5_2) /ext/xmlrpc xmlrpc-epi-php.c /ext/xmlrpc/tests bug45555.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-51236@lists.php.net to get a copy of this message | ||
felipe Fri Jul 18 15:52:38 2008 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/xmlrpc/tests bug45555.phpt
Modified files:
/php-src/ext/xmlrpc xmlrpc-epi-php.c
Log:
- Fixed bug #45555 (Segfault with invalid non-string as register_introspection_callback)
(patch by chris_se at gmx dot ne)
http://cvs.php.net/viewvc.cgi/php-src/ext/xmlrpc/xmlrpc-epi-php.c?r1=1.39.2.5.2.9&r2=1.39.2.5.2.10&diff_format=u
Index: php-src/ext/xmlrpc/xmlrpc-epi-php.c
diff -u php-src/ext/xmlrpc/xmlrpc-epi-php.c:1.39.2.5.2.9
php-src/ext/xmlrpc/xmlrpc-epi-php.c:1.39.2.5.2.10
--- php-src/ext/xmlrpc/xmlrpc-epi-php.c:1.39.2.5.2.9 Fri Jul 18 14:56:58 2008
+++ php-src/ext/xmlrpc/xmlrpc-epi-php.c Fri Jul 18 15:52:38 2008
@@ -51,7 +51,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xmlrpc-epi-php.c,v 1.39.2.5.2.9 2008/07/18 14:56:58 felipe Exp $ */
+/* $Id: xmlrpc-epi-php.c,v 1.39.2.5.2.10 2008/07/18 15:52:38 felipe Exp $ */
/**********************************************************************
* BUGS: *
@@ -879,6 +879,7 @@
{
zval *retval_ptr, **php_function;
zval* callback_params[1];
+ char *php_function_name;
xmlrpc_callback_data* pData = (xmlrpc_callback_data*)data;
TSRMLS_FETCH();
@@ -893,35 +894,39 @@
while(1) {
if(zend_hash_get_current_data(Z_ARRVAL_P(pData->server->introspection_map),
(void**)&php_function) == SUCCESS) {
- /* php func prototype: function string user_func($user_params) */
- if(call_user_function(CG(function_table), NULL, *php_function, retval_ptr, 1, callback_params
TSRMLS_CC) == SUCCESS) {
- XMLRPC_VALUE xData;
- STRUCT_XMLRPC_ERROR err = {0};
-
- /* return value should be a string */
- convert_to_string(retval_ptr);
-
- xData = XMLRPC_IntrospectionCreateDescription(Z_STRVAL_P(retval_ptr), &err);
-
- if(xData) {
- if(!XMLRPC_ServerAddIntrospectionData(server, xData)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add introspection data returned
from %s(), improper element structure", Z_STRVAL_PP(php_function));
- }
- XMLRPC_CleanupValue(xData);
- } else {
- /* could not create description */
- if(err.xml_elem_error.parser_code) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "xml parse error: [line %ld, column %ld,
message: %s] Unable to add introspection data returned from %s()",
- err.xml_elem_error.column, err.xml_elem_error.line, err.xml_elem_error.parser_error,
Z_STRVAL_PP(php_function));
+ if (zend_is_callable(*php_function, 0, &php_function_name)) {
+ /* php func prototype: function string user_func($user_params) */
+ if (call_user_function(CG(function_table), NULL, *php_function, retval_ptr, 1, callback_params
TSRMLS_CC) == SUCCESS) {
+ XMLRPC_VALUE xData;
+ STRUCT_XMLRPC_ERROR err = {0};
+
+ /* return value should be a string */
+ convert_to_string(retval_ptr);
+
+ xData = XMLRPC_IntrospectionCreateDescription(Z_STRVAL_P(retval_ptr), &err);
+
+ if(xData) {
+ if(!XMLRPC_ServerAddIntrospectionData(server, xData)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add introspection data returned
from %s(), improper element structure", php_function_name);
+ }
+ XMLRPC_CleanupValue(xData);
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add introspection data returned
from %s()",
- Z_STRVAL_PP(php_function));
+ /* could not create description */
+ if(err.xml_elem_error.parser_code) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "xml parse error: [line %ld, column %ld,
message: %s] Unable to add introspection data returned from %s()",
+ err.xml_elem_error.column, err.xml_elem_error.line, err.xml_elem_error.parser_error,
php_function_name);
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to add introspection data returned
from %s()", php_function_name);
+ }
}
+ } else {
+ /* user func failed */
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error calling user introspection callback:
%s()", php_function_name);
}
} else {
- /* user func failed */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error calling user introspection callback:
%s()", Z_STRVAL_PP(php_function));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid callback '%s' passed",
php_function_name);
}
+ efree(php_function_name);
} else {
break;
}
http://cvs.php.net/viewvc.cgi/php-src/ext/xmlrpc/tests/bug45555.phpt?view=markup&rev=1.1
Index: php-src/ext/xmlrpc/tests/bug45555.phpt
+++ php-src/ext/xmlrpc/tests/bug45555.phpt