From: Antony Dovgal Date: Mon, 14 Aug 2006 08:15:44 +0000 (+0000) Subject: fix segfault and leak in ext/xmlrpc X-Git-Tag: RELEASE_1_0_0RC1~1972 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cf400175ea03dc9aa702812270458b8d172c8681;p=php fix segfault and leak in ext/xmlrpc add tests --- diff --git a/ext/xmlrpc/tests/001.phpt b/ext/xmlrpc/tests/001.phpt new file mode 100644 index 0000000000..99fd958d29 --- /dev/null +++ b/ext/xmlrpc/tests/001.phpt @@ -0,0 +1,66 @@ +--TEST-- +xmlrpc_encode_request() with wrong arguments +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(174) " + +-1 + + + + 1 + + + + +" +string(160) " + + + + + + 1 + + + + +" + +Notice: Array to string conversion in %s on line %d +string(177) " + +Array + + + + 1 + + + + +" +string(175) " + +3.4 + + + + 1 + + + + +" +Done diff --git a/ext/xmlrpc/tests/002.phpt b/ext/xmlrpc/tests/002.phpt new file mode 100644 index 0000000000..c8d722b808 --- /dev/null +++ b/ext/xmlrpc/tests/002.phpt @@ -0,0 +1,56 @@ +--TEST-- +xmlrpc_encode_request() and various arguments +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +array(0) { +} +string(6) "method" +array(1) { + [0]=> + int(1) +} +string(6) "method" +array(1) { + [0]=> + string(5) "param" +} +string(6) "method" +array(1) { + [0]=> + string(0) "" +} +string(2) "-1" + +Notice: Array to string conversion in %s on line %d +array(1) { + [0]=> + int(1) +} +string(5) "Array" +Done diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c index aa3867f29f..4838dfb1b2 100644 --- a/ext/xmlrpc/xmlrpc-epi-php.c +++ b/ext/xmlrpc/xmlrpc-epi-php.c @@ -670,6 +670,7 @@ PHP_FUNCTION(xmlrpc_encode_request) if (Z_TYPE_PP(method) == IS_NULL) { XMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_response); } else { + convert_to_string_ex(method); XMLRPC_RequestSetMethodName(xRequest, Z_STRVAL_PP(method)); XMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_call); } @@ -739,7 +740,7 @@ zval* decode_request_worker (zval* xml_in, zval* encoding_in, zval* method_name_ if(XMLRPC_RequestGetRequestType(response) == xmlrpc_request_call) { if(method_name_out) { - convert_to_string(method_name_out); + zval_dtor(method_name_out); Z_TYPE_P(method_name_out) = IS_STRING; Z_STRVAL_P(method_name_out) = estrdup(XMLRPC_RequestGetMethodName(response)); Z_STRLEN_P(method_name_out) = strlen(Z_STRVAL_P(method_name_out));