Skip to content

Commit e6994ef

Browse files
committed
fix: increase rpcbind check robustness
Adds invalid rpcbind port checking to `HTTPBindAddresses()`. While movement of `CheckHostPortOptions()` in the previous commit handles rcpbind port errors, updating `HTTPBindAddresses()` port checking adds a defensive measure for potential future changes.
1 parent d38e3ae commit e6994ef

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/httpserver.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <chainparamsbase.h>
1010
#include <common/args.h>
11+
#include <common/messages.h>
1112
#include <compat/compat.h>
1213
#include <logging.h>
1314
#include <netbase.h>
@@ -43,6 +44,8 @@
4344

4445
#include <support/events.h>
4546

47+
using common::InvalidPortErrMsg;
48+
4649
/** Maximum size of http request (request line + headers) */
4750
static const size_t MAX_HEADERS_SIZE = 8192;
4851

@@ -374,7 +377,10 @@ static bool HTTPBindAddresses(struct evhttp* http)
374377
for (const std::string& strRPCBind : gArgs.GetArgs("-rpcbind")) {
375378
uint16_t port{http_port};
376379
std::string host;
377-
SplitHostPort(strRPCBind, port, host);
380+
if (!SplitHostPort(strRPCBind, port, host)) {
381+
LogError("%s\n", InvalidPortErrMsg("-rpcbind", strRPCBind).original);
382+
return false;
383+
}
378384
endpoints.emplace_back(host, port);
379385
}
380386
}

0 commit comments

Comments
 (0)