Skip to content

Commit 2a40ee1

Browse files
committed
rpc: check for negative timeout arg in waitfor*
1 parent de7c855 commit 2a40ee1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/rpc/blockchain.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ static RPCHelpMan waitfornewblock()
296296
int timeout = 0;
297297
if (!request.params[0].isNull())
298298
timeout = request.params[0].getInt<int>();
299+
if (timeout < 0) throw JSONRPCError(RPC_MISC_ERROR, "Negative timeout");
299300

300301
CUpdatedBlock block;
301302
{
@@ -343,6 +344,7 @@ static RPCHelpMan waitforblock()
343344

344345
if (!request.params[1].isNull())
345346
timeout = request.params[1].getInt<int>();
347+
if (timeout < 0) throw JSONRPCError(RPC_MISC_ERROR, "Negative timeout");
346348

347349
CUpdatedBlock block;
348350
{
@@ -391,6 +393,7 @@ static RPCHelpMan waitforblockheight()
391393

392394
if (!request.params[1].isNull())
393395
timeout = request.params[1].getInt<int>();
396+
if (timeout < 0) throw JSONRPCError(RPC_MISC_ERROR, "Negative timeout");
394397

395398
CUpdatedBlock block;
396399
{

0 commit comments

Comments
 (0)