pajoye                                   Wed, 03 Feb 2010 20:19:05 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=294452

Log:
- Fixed bug #50761 (system.multiCall crashes in xmlrpc extension).

Bug: http://bugs.php.net/50761 (Closed) system.multiCall crashes
      
Changed paths:
    _U  php/php-src/branches/PHP_5_3_2/
    _U  php/php-src/branches/PHP_5_3_2/ext/tidy/tests/
    A + php/php-src/branches/PHP_5_3_2/ext/xmlrpc/tests/bug50761.phpt
        (from 
php/php-src/branches/PHP_5_3/ext/xmlrpc/tests/bug50761.phpt:r293655)
    U   php/php-src/branches/PHP_5_3_2/ext/xmlrpc/xmlrpc-epi-php.c
    _U  
php/php-src/branches/PHP_5_3_2/tests/security/open_basedir_parse_ini_file.phpt


Property changes on: php/php-src/branches/PHP_5_3_2
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/php/php-src/branches/PHP_5_3:292504,292574,292594-292595,292611,292624,292630,292632-292635,292654,292677,292682-292683,292693,292719,292762,292765,292771,292777,292823,293051,293075,293114,293126,293131,293144,293146,293152,293176,293180,293216,293235,293253,293268,293341,293380,293400,293442,293447,293466,293502,293538,293548,293558,293597,293627,293644,293653,293974
/php/php-src/trunk:284726
   + 
/php/php-src/branches/PHP_5_3:292504,292574,292594-292595,292611,292624,292630,292632-292635,292654,292677,292682-292683,292693,292719,292762,292765,292771,292777,292823,293051,293075,293114,293126,293131,293144,293146,293152,293176,293180,293216,293235,293253,293268,293341,293380,293400,293442,293447,293466,293502,293538,293548,293558,293597,293627,293644,293653,293655,293974
/php/php-src/trunk:284726


Property changes on: php/php-src/branches/PHP_5_3_2/ext/tidy/tests
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/php/php-src/branches/PHP_5_3/ext/tidy/tests:292562,292566,292571,292574,292635,292719,292765,293146,293152,293176,293180,293216,293235,293253,293380,293400,293442,293447,293466,293502,293538,293548,293558,293597,293627,293644,293653
/php/php-src/trunk/ext/tidy/tests:284726,287798-287941
   + 
/php/php-src/branches/PHP_5_3/ext/tidy/tests:292562,292566,292571,292574,292635,292719,292765,293146,293152,293176,293180,293216,293235,293253,293380,293400,293442,293447,293466,293502,293538,293548,293558,293597,293627,293644,293653,293655
/php/php-src/trunk/ext/tidy/tests:284726,287798-287941

Copied: php/php-src/branches/PHP_5_3_2/ext/xmlrpc/tests/bug50761.phpt (from rev 
293655, php/php-src/branches/PHP_5_3/ext/xmlrpc/tests/bug50761.phpt)
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/xmlrpc/tests/bug50761.phpt               
                (rev 0)
+++ php/php-src/branches/PHP_5_3_2/ext/xmlrpc/tests/bug50761.phpt       
2010-02-03 20:19:05 UTC (rev 294452)
@@ -0,0 +1,62 @@
+--TEST--
+Bug #50761 (system.multiCall crashes)
+--FILE--
+<?php
+$req = '<?xml version="1.0"?>
+<methodCall>
+<methodName>system.multiCall</methodName>
+<params><param><value><array><data>
+<value><struct>
+<member><name>methodName</name><value><string>testMethodA</string></value></member>
+<member><name>params</name><value><array><data><value><string>A</string>
+</value></data></array></value></member>
+</struct></value>
+<value><struct>
+<member><name>methodName</name><value><string>testMethodB</string></value></member>
+<member><name>params</name><value><array><data><value><string>B</string>
+</value></data></array></value></member>
+</struct></value>
+</data></array></value></param></params>
+</methodCall>';
+
+function testA($methodName, $params, $var){ return "C"; }
+function testB($methodName, $params, $var){ return "D"; }
+
+$server = xmlrpc_server_create();
+xmlrpc_server_register_method($server, 'testMethodA', 'testA');
+xmlrpc_server_register_method($server, 'testMethodB', 'testB');
+$res = xmlrpc_server_call_method($server, $req, null);
+echo $res;
+?>
+--EXPECT--
+<?xml version="1.0" encoding="iso-8859-1"?>
+<methodResponse>
+<params>
+ <param>
+  <value>
+   <array>
+    <data>
+     <value>
+      <array>
+       <data>
+        <value>
+         <string>C</string>
+        </value>
+       </data>
+      </array>
+     </value>
+     <value>
+      <array>
+       <data>
+        <value>
+         <string>D</string>
+        </value>
+       </data>
+      </array>
+     </value>
+    </data>
+   </array>
+  </value>
+ </param>
+</params>
+</methodResponse>

Modified: php/php-src/branches/PHP_5_3_2/ext/xmlrpc/xmlrpc-epi-php.c
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/xmlrpc/xmlrpc-epi-php.c  2010-02-03 
20:16:21 UTC (rev 294451)
+++ php/php-src/branches/PHP_5_3_2/ext/xmlrpc/xmlrpc-epi-php.c  2010-02-03 
20:19:05 UTC (rev 294452)
@@ -911,13 +911,27 @@
 static XMLRPC_VALUE php_xmlrpc_callback(XMLRPC_SERVER server, XMLRPC_REQUEST 
xRequest, void* data) /* {{{ */
 {
        xmlrpc_callback_data* pData = (xmlrpc_callback_data*)data;
+       zval** php_function;
        zval* xmlrpc_params;
        zval* callback_params[3];
        TSRMLS_FETCH();

+       zval_dtor(pData->xmlrpc_method);
+       zval_dtor(pData->return_data);
+
        /* convert xmlrpc to native php types */
+       ZVAL_STRING(pData->xmlrpc_method, 
XMLRPC_RequestGetMethodName(xRequest), 1);
        xmlrpc_params = XMLRPC_to_PHP(XMLRPC_RequestGetData(xRequest));
+
+       /* check if the called method has been previous registered */
+       if(zend_hash_find(Z_ARRVAL_P(pData->server->method_map),
+                      Z_STRVAL_P(pData->xmlrpc_method),
+                      Z_STRLEN_P(pData->xmlrpc_method) + 1,
+                      (void**)&php_function) == SUCCESS) {

+               pData->php_function = *php_function;
+       }
+
        /* setup data hoojum */
        callback_params[0] = pData->xmlrpc_method;
        callback_params[1] = xmlrpc_params;
@@ -932,7 +946,7 @@

        zval_ptr_dtor(&xmlrpc_params);

-       return NULL;
+       return PHP_to_XMLRPC(pData->return_data TSRMLS_CC);
 }
 /* }}} */

@@ -1101,34 +1115,17 @@

                if (xRequest) {
                        const char* methodname = 
XMLRPC_RequestGetMethodName(xRequest);
-                       zval **php_function;
                        XMLRPC_VALUE xAnswer = NULL;
                        MAKE_STD_ZVAL(data.xmlrpc_method); /* init. very 
important.  spent a frustrating day finding this out. */
                        MAKE_STD_ZVAL(data.return_data);
                        Z_TYPE_P(data.return_data) = IS_NULL;  /* in case value 
is never init'd, we don't dtor to think it is a string or something */
                        Z_TYPE_P(data.xmlrpc_method) = IS_NULL;

-                       if (!methodname) {
-                               methodname = "";
-                       }
-
                        /* setup some data to pass to the callback function */
-                       Z_STRVAL_P(data.xmlrpc_method) = estrdup(methodname);
-                       Z_STRLEN_P(data.xmlrpc_method) = strlen(methodname);
-                       Z_TYPE_P(data.xmlrpc_method) = IS_STRING;
                        data.caller_params = *caller_params;
                        data.php_executed = 0;
                        data.server = server;

-                       /* check if the called method has been previous 
registered */
-                       if (zend_hash_find(Z_ARRVAL_P(server->method_map),
-                                                               
Z_STRVAL_P(data.xmlrpc_method),
-                                                               
Z_STRLEN_P(data.xmlrpc_method) + 1,
-                                                               
(void**)&php_function) == SUCCESS) {
-
-                               data.php_function = *php_function;
-                       }
-
                        /* We could just call the php method directly ourselves 
at this point, but we do this
                         * with a C callback in case the xmlrpc library ever 
implements some cool usage stats,
                         * or somesuch.
@@ -1138,7 +1135,7 @@
                                zval_dtor(data.return_data);
                                FREE_ZVAL(data.return_data);
                                data.return_data = XMLRPC_to_PHP(xAnswer);
-                       } else if (data.php_executed && !out.b_php_out) {
+                       } else if (data.php_executed && !out.b_php_out && 
!xAnswer) {
                                xAnswer = PHP_to_XMLRPC(data.return_data 
TSRMLS_CC);
                        }



Property changes on: 
php/php-src/branches/PHP_5_3_2/tests/security/open_basedir_parse_ini_file.phpt
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/php/php-src/branches/PHP_5_3/tests/security/open_basedir_parse_ini_file.phpt:292562,292566,292571,292574,293146,293152,293176,293180,293216,293235,293253,293380,293400,293442,293447,293466,293502,293538,293548,293558,293597,293627,293644,293653
/php/php-src/trunk/tests/security/open_basedir_parse_ini_file.phpt:265951
   + 
/php/php-src/branches/PHP_5_3/tests/security/open_basedir_parse_ini_file.phpt:292562,292566,292571,292574,293146,293152,293176,293180,293216,293235,293253,293380,293400,293442,293447,293466,293502,293538,293548,293558,293597,293627,293644,293653,293655
/php/php-src/trunk/tests/security/open_basedir_parse_ini_file.phpt:265951

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to