Skip to content

Commit ae69e05

Browse files
committed
cleanup parameter parsing
1 parent 0855be0 commit ae69e05

File tree

4 files changed

+17
-31
lines changed

4 files changed

+17
-31
lines changed

ext/xmlrpc/tests/001.phpt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,8 @@ string(160) "<?xml version="1.0" encoding="iso-8859-1"?>
3838
</methodCall>
3939
"
4040

41-
Notice: Array to string conversion in %s on line %d
42-
string(177) "<?xml version="1.0" encoding="iso-8859-1"?>
43-
<methodCall>
44-
<methodName>Array</methodName>
45-
<params>
46-
<param>
47-
<value>
48-
<int>1</int>
49-
</value>
50-
</param>
51-
</params>
52-
</methodCall>
53-
"
41+
Warning: xmlrpc_encode_request() expects parameter 1 to be string, array given in %s on line %d
42+
NULL
5443
string(175) "<?xml version="1.0" encoding="iso-8859-1"?>
5544
<methodCall>
5645
<methodName>3.4</methodName>

ext/xmlrpc/tests/002.phpt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ array(1) {
4747
}
4848
string(2) "-1"
4949

50-
Notice: Array to string conversion in %s on line %d
51-
array(1) {
52-
[0]=>
53-
int(1)
54-
}
55-
string(5) "Array"
50+
Warning: xmlrpc_encode_request() expects parameter 1 to be string, array given in %s on line %d
51+
NULL
52+
string(2) "-1"
5653
Done

ext/xmlrpc/tests/bug42189.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ var_dump($ok);
1111
echo "Done\n";
1212
?>
1313
--EXPECT--
14-
bool(true)
14+
bool(false)
1515
Done

ext/xmlrpc/xmlrpc-epi-php.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -688,10 +688,12 @@ PHP_FUNCTION(xmlrpc_encode_request)
688688
{
689689
XMLRPC_REQUEST xRequest = NULL;
690690
char *outBuf;
691-
zval **method, **vals, *out_opts = NULL;
691+
zval *vals, *out_opts = NULL;
692+
char *method = NULL;
693+
int method_len;
692694
php_output_options out;
693695

694-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZ|a", &method, &vals, &out_opts) == FAILURE) {
696+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!z|a", &method, &method_len, &vals, &out_opts) == FAILURE) {
695697
return;
696698
}
697699

@@ -702,15 +704,14 @@ PHP_FUNCTION(xmlrpc_encode_request)
702704

703705
if (xRequest) {
704706
XMLRPC_RequestSetOutputOptions(xRequest, &out.xmlrpc_out);
705-
if (Z_TYPE_PP(method) == IS_NULL) {
707+
if (method == NULL) {
706708
XMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_response);
707709
} else {
708-
convert_to_string_ex(method);
709-
XMLRPC_RequestSetMethodName(xRequest, Z_STRVAL_PP(method));
710+
XMLRPC_RequestSetMethodName(xRequest, method);
710711
XMLRPC_RequestSetRequestType(xRequest, xmlrpc_request_call);
711712
}
712-
if (Z_TYPE_PP(vals) != IS_NULL) {
713-
XMLRPC_RequestSetData(xRequest, PHP_to_XMLRPC(*vals TSRMLS_CC));
713+
if (Z_TYPE_P(vals) != IS_NULL) {
714+
XMLRPC_RequestSetData(xRequest, PHP_to_XMLRPC(vals TSRMLS_CC));
714715
}
715716

716717
outBuf = XMLRPC_REQUEST_ToXML(xRequest, 0);
@@ -800,7 +801,6 @@ PHP_FUNCTION(xmlrpc_decode_request)
800801
return;
801802
}
802803

803-
convert_to_string_ex(method);
804804

805805
if (return_value_used) {
806806
zval* retval = decode_request_worker(xml, xml_len, encoding_len ? encoding : NULL, *method);
@@ -1061,20 +1061,20 @@ PHP_FUNCTION(xmlrpc_server_call_method)
10611061
XMLRPC_REQUEST xRequest;
10621062
STRUCT_XMLRPC_REQUEST_INPUT_OPTIONS input_opts;
10631063
xmlrpc_server_data* server;
1064-
zval **caller_params, *handle, **output_opts = NULL;
1064+
zval **caller_params, *handle, *output_opts = NULL;
10651065
char *rawxml;
10661066
int rawxml_len, type;
10671067
php_output_options out;
10681068
int argc =ZEND_NUM_ARGS();
10691069

1070-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsZ|Z", &handle, &rawxml, &rawxml_len, &caller_params, &output_opts) != SUCCESS) {
1070+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsZ|a", &handle, &rawxml, &rawxml_len, &caller_params, &output_opts) != SUCCESS) {
10711071
return;
10721072
}
10731073
/* user output options */
10741074
if (argc == 3) {
10751075
set_output_options(&out, NULL);
10761076
} else {
1077-
set_output_options(&out, *output_opts);
1077+
set_output_options(&out, output_opts);
10781078
}
10791079

10801080
server = zend_list_find(Z_LVAL_P(handle), &type);

0 commit comments

Comments
 (0)