Skip to content

Commit fa50bdc

Browse files
author
MarcoFalke
committed
rpc: Limit echo to 10 args
1 parent fa89ca9 commit fa50bdc

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/rpc/misc.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,16 +583,29 @@ static UniValue echo(const JSONRPCRequest& request)
583583
throw std::runtime_error(
584584
RPCHelpMan{"echo|echojson ...",
585585
"\nSimply echo back the input arguments. This command is for testing.\n"
586-
"\nIt will return an internal bug report when exactly 100 arguments are passed.\n"
586+
"\nIt will return an internal bug report when arg9='trigger_internal_bug' is passed.\n"
587587
"\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in "
588588
"bitcoin-cli and the GUI. There is no server-side difference.",
589-
{},
589+
{
590+
{"arg0", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
591+
{"arg1", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
592+
{"arg2", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
593+
{"arg3", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
594+
{"arg4", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
595+
{"arg5", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
596+
{"arg6", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
597+
{"arg7", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
598+
{"arg8", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
599+
{"arg9", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, ""},
600+
},
590601
RPCResult{RPCResult::Type::NONE, "", "Returns whatever was passed in"},
591602
RPCExamples{""},
592603
}.ToString()
593604
);
594605

595-
CHECK_NONFATAL(request.params.size() != 100);
606+
if (request.params[9].isStr()) {
607+
CHECK_NONFATAL(request.params[9].get_str() != "trigger_internal_bug");
608+
}
596609

597610
return request.params;
598611
}

test/functional/rpc_misc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def run_test(self):
2727
self.log.info("test CHECK_NONFATAL")
2828
assert_raises_rpc_error(
2929
-1,
30-
"Internal bug detected: 'request.params.size() != 100'",
31-
lambda: node.echo(*[0] * 100),
30+
'Internal bug detected: \'request.params[9].get_str() != "trigger_internal_bug"\'',
31+
lambda: node.echo(arg9='trigger_internal_bug'),
3232
)
3333

3434
self.log.info("test getmemoryinfo")

0 commit comments

Comments
 (0)